home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ for Dummies (3rd Edition)
/
C_FD.iso
/
CHAP12
/
CHAP12_5.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-02
|
693b
|
39 lines
// Chap12_5.cpp (This version works as compared with 12_4)
#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) : id(ssId)
{
cout << "Constructing student " << pName << "\n";
strncpy(name, pName, sizeof(name));
name[sizeof(name) - 1] = '\0';
}
protected:
char name[40];
StudentId id;
};
int main()
{
Student s("Randy", 1234);
cout << "This message from main\n";
return 0;
}