Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Derived classes and function parameters...

Status
Not open for further replies.
1. Copy "#define ARY 100" to the h file.
2. Change the data members to:
char cFName [ARY];
char cLName [ARY];

3 Remove those statements from the constructor.
 
Also - your class data members (cFname, cLname, and iIDNumber) should be either protected or private. They should not be directly accessible outside the scope of your class. This is good programming practice, but on a more fundamental level, data hiding is the whole point of C++ classes.

Add Get and Set member functions to your class header file to alter their values, ie:

int GetIDNumber() { return iIDNumber; }
void SetIDNumber(int id) { iIDNumber = id; }

Also, try using the C++ 'string' class rather than the old C style strings (char lpszStr[]) by including <string> in your header or source files.

#include <string> // not <string.h>

A C++ string is a template collection class that will help avoid the nasty invalid pointer errors you can get using C strings, ie:

char lpszCity[] = {&quot;London&quot;};
char cChar = lpszCity[7]; // error!

Alternatively, include the MFC library in your project settings and use the CString class. Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top