关于类的问题
下面这个程序是我按书上的来写的,怎么运行不出来啊??顺便说一下,我用的是Dev-C++。
谢谢。
#include <iostream.h>
class family
{
private:
char *husband;
char *wife;
char *son;
char *daughter;
family *ptr;
public:
void initialize(void);
friend void output(family *ptr);
}
family Anderson;
void output(family *ptr);
main(void)
{
Anderson.initialize();
}
void family::initialize(void)
{
Anderson.ptr=&Anderson;
ptr->husband="John Anderson";
ptr->wife="Mary Anderson";
ptr->son="Joey Anderson";
ptr->daughter="Marla Anderson";
output(ptr);
}
void output(family *ptr)
{
cout<<"husband is "<<ptr->husband<<"\n"
<<"wife is "<<ptr->wife<<"\n"
<<"son is "<<ptr->son<<"\n"
<<"daughter is"<<ptr->daughter<<"\n"
}