Advertisement

Code Error

Started by April 02, 2002 11:17 PM
9 comments, last by GoldenOne 22 years, 8 months ago
Never mind...I found my mistake. I learned that I needed to assign the private member.


  #include <iostream>using namespace std;class terran 	{	private: 		char * m_unitname;		int m_health;	public:		terran();		terran(char * unitname, int health);		void show();	};int main()	{	terran obj1("hey", 10);	obj1.show();	return 0;	}void terran::show()	{	cout << m_unitname;	cout << m_health;	}terran::terran(char *unitname, int health){	m_health = health;	m_unitname = unitname;}  


I needed the last function. I needed to, again, assign the private thing to a number/name.

This topic is closed to new replies.

Advertisement