Subj : Re: problem about class i have to do to send my teacher To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Sun Sep 12 2004 05:29 pm In addition to what Mr Maeder has told you: In this constructor: Info::Info(char N[], int A) : age(A) { strcpy(name, N); } The character array called 'name' has 30 elements so can at most hold 29 characters plus the string termination character. No checking is done on the validity or length of 'N'. Expect a problem if N is NULL or disaster if the string referenced by the name N is greater than 29 characters. Investigate the strlen and strncpy functions. In this constructor: Manager::Manager(char N[],int A,char P[]) : Info(N,A), position(P) { } The member variable 'position' is the name of an array of 20 elements. The calling argument 'P' is a 'char*' or pointer to char, a variable which contains the address of the a character. You knew something about how to handle this situation when you wrote the constructor for class 'Info'. Apply that knowledge to the constructor for class 'Manager'. In the function 'main' there are these lines: Manager("abz",25,"manager"); That declares an instance of class 'Manager' yet fails to declare a variable which is the name of the instance. The instance is created but because there is no name with which to reference it, the instance cannot be used by any of the code. Manager.DisPlayManager(); 'DisPlayManager' is a normal member function of class 'Manager'. It uses the member variables contained in the class instance. The code line does not specify the name of an instance of the class. .. Ed > briham wrote in message > news:41447047@newsgroups.borland.com... > >i have an home work about class this is what i do. what i'm done >wrong thank you > > #include > #include > #include > using namespace std; > class Info > { > public: > char name[30]; > int age; > Info(char[],int); > ~Info() {}; > void DisPlayInfo(void); > }; > > Info::Info(char N[],int A) : age(A) { > strcpy(name,N); > > } > void Info::DisPlayInfo(void) > > { > cout << "First Name is" << name << "\n"; > cout << "Age is" << age << "\n"; > } > > class Manager : Info > { > char position[20]; > public: > void DisPlayManager(void); > Manager(char [], int , char []); > }; > > Manager::Manager(char N[],int A,char P[]) : Info(N,A), position(P) > { > > } > > void Manager::DisPlayManager(void) > { > cout << "First Name is" << name << "\n"; > cout << "Age is" << age << "\n"; > cout << "Position is" << position << "\n"; > } > > void Main() > { > clrscr(); > Manager("abz",25,"manager"); > Manager.DisPlayManager(); > > getche(); > } .