home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ for Dummies (3rd Edition)
/
C_FD.iso
/
CHAP12
/
CHAP12_3.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-02
|
603b
|
37 lines
// Chap12_3.cpp
#include <iostream.h>
#include <string.h>
int nextStudentId = 0;
class StudentId
{
public:
StudentId()
{
value = ++nextStudentId;
cout << "Assigning student id " << value << "\n";
}
protected:
int value;
};
class Student
{
public:
Student(char *pName = "no name")
{
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");
return 0;
}