新微赢技术网
标题:
c++第一个对象程序出错了帮忙看一下
[打印本页]
作者:
爱情tp乞丐
时间:
2009-11-3 04:07
标题:
c++第一个对象程序出错了帮忙看一下
#include<iostream.h>
class family
{
private:
char *fname;
char *mname;
char *son;
char *girl;
family *ptr;
public:
void initfa(void);
void outfa(family *ptr);
};
family family1;
void family::outfa(family *ptr)
{
cout<<"family1的成员列表"<<endl;
cout<<"------------------------------------"<<endl;
cout<<"fname "<<ptr->fname<<endl;
cout<<"mname "<<ptr->manem<<endl;
cout<<"son "<<ptr->son<<endl;
cout<<"girl "<<ptr->girl<<endl;
cout<<"------------------------------------"<<endl;
}
void family::initfa(void)
{
family1.ptr=&family1;
family1.ptr->fname="父亲";
family1.ptr->mmane="母亲";
family1.ptr->son="儿子";
family1.ptr->girl="女儿";
family1.outfa(family1.ptr);
}
void main(void)
{
family1.initfa(void);
}
出错信息:
执行 cl.exe 时出错.
hello.exe - 1 error(s), 0 warning(s)
作者:
ξǒひ糀無蒛
时间:
2009-11-3 04:07
cout<<"mname "<<ptr->manem<<endl; //ptr->mname
family1.ptr->mmane="母亲"; //ptr->mname
family1.initfa(void); //family1.initfa();
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2