home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ for Dummies (3rd Edition)
/
C_FD.iso
/
CHAP12
/
CHAP12_4.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-02
|
784b
|
40 lines
// Chap12_4.cpp (Note that this program doesn't work)
#include <iostream.h>
#include <string.h>
class StudentId
{
public:
StudentId(int id = 0)
{
value = id;
cout << "Assigning student id " << value << "\n";
}
protected:
int value;
};
class Student
{
public:
Student(char *pName = "no name", int ssId = 0)
{
cout << "Constructing student " << pName << "\n";
strncpy(name, pName, sizeof(name));
name[sizeof(name) - 1] = '\0';
//donÆt try this at home kids. It doesnÆt work
StudentId id(ssId); //construct a student id
}
protected:
char name[40];
StudentId id;
};
int main()
{
Student s("Randy", 1234);
cout << "This message from main\n";
return 0;
}