CHAPTER2-8.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER2-8.cpp
- #include<iostream.h>
- #include<string.h>
- class Student
- {
- friend ostream& operator<<(ostream& ot, Student& popup);
- char name[10];
- unsigned int age;
- unsigned long num;
- public:
- Student(char *na, unsigned int al, unsigned long number):
- age(al), num(number)
- {
- strcpy(name, na);
- }
- };
- ostream& operator<<(ostream& ot, Student& popup)
- {
- ot<<"Name"<<popup.name<<endl<<"Age"<<popup.age<<endl<<"Number:"
- <<popup.num<<endl<<"------------------------"<<endl;
- return ot;
- }
- void main()
- {
- Student a("Wang",18,1234),b("Zhao",19,4321),c("Liu",20,2134);
- cout<<a<<b<<c;
- }