Papers/Others
C++ Static variable
tomato13
2006. 11. 2. 13:37
http://blog.naver.com/mw__?Redirect=Log&logNo=60013205387
#include <iostream.h>
#include <conio.h>
#include <string.h>
class person {
private:
char name[25];
static long num;
public:
person(char*, long);
void output();
};
long person::num;
person::person(char* name, long num)
{
strcpy(person::name, name);
person::num = num;
}
void person::output()
{
cout << "Name: " << name << endl;
cout << "Hacbun: " << num << endl << endl;
}
void main()
{
person per("Hong Gil Dong", 1998123);
per.output();
cout << "Press any key for other member..." << endl;
getch();
person man("Lee Soon Sin", 200567);
man.output();
per.output();
}