#ifndef LINKSHOW
#define LINKSHOW
typedef struct student
{
int num;
char sex;
}Per,* per;
#endif#ifndef LINKHEAD
#define LINKHEAD
typedef struct person
{
long int num;
char name[20];
char sex;
float scpre;
per test;
}Stud;
#endifvoid main()
{
Stud * p= new Stud;
p->num=1000;
strcpy(p->name,"li lin");
p->sex='M';
p->scpre=2000; p->test->num=1000; //????
p->test->sex='n'; //???? cout<<"The name:"<<p->name<<endl;
cout<<"The Num:"<<p->num<<endl;
cout<<"The sex:"<<p->sex<<endl;
cout<<"the score"<<p->scpre<<endl; cout<<" \n";
cout<<p->test->num<<endl;//???
cout<<p->test->sex<<endl; //????
}
解决方案 »
- 用VC开发的程序要正常运行,都必须先安装VCRedist包吗???
- vc6的自动提示功能不能使用了
- update excel中的记录出现语法错误和违反访问规则,请问哪位大虾看看是什么原因啊。
- 为什么QQ登录后多出这么多udp端口?
- 请问怎样用win32 API 读出指定进程在内存中的所有数据?
- 开发黑Q软件的流程内幕
- 获取局域网内,所有的机器的网卡地址!
- 马的,同样的代码,不同的结果?
- 提取图中用某种单一颜色矩形框标注的图像内容,并将其保存为BMP格式的文件。
- strcp、strcat到底还做了些什么??????????(交出我所有的分!!!)
- 关于CList删除节点的问题
- 请问GDI+中如何使用new来进行对象构造?
#define LINKSHOW
typedef struct student
{
int num;
char sex;
}Per,* per;
#endif#ifndef LINKHEAD
#define LINKHEAD
typedef struct person
{
long int num;
char name[20];
char sex;
float scpre;
per test;
}Stud;
#endif
void main()
{
Stud * p= new Stud;
p->num=1000;
strcpy(p->name,"li lin");
p->sex='M';
p->scpre=2000;
//Per * test=new Per;
p->test.num=1000;
p->test.sex='n';
cout<<"The name:"<<p->name<<endl;
cout<<"The Num:"<<p->num<<endl;
cout<<"The sex:"<<p->sex<<endl;
cout<<"the score"<<p->scpre<<endl; cout<<" \n";
cout<<p->test.num<<endl;
cout<<p->test.sex<<endl;
}
用结构变量,如上所示.
typedef struct person
{
long int num;
char name[20];
char sex;
float scpre;
per test; //你这里定义的是一个Per型的指针,最好把per改成Per,如果一定要用指针,最好用类,不要用结构,并且要重载类的拷贝函数
}Stud;p->test.num=1000; //这里你有两个错误,第一就是你的test指针没有初始话:p->tet=new Per;
p->test.sex='n'; //第二就是你的.要改成->,比如:p->test->num=1000;
#define LINKSHOW
typedef struct student
{
int num;
char sex;
}Per,* per;
#endif
来作为一个类,又如何来并且要重载类的拷贝函数,我有点晕,请指教???
类是否要这样定义
class CPer
{
public:
int GetNum(){return num;}
char GetInt(){return sex}
private:
int num;
char sex;}
typedef struct person
{
long int num;
char name[20];
char sex;
float scpre;
per test;
}Stud;
中包含了Per型的指针test,为了更好的管理test指向的对象,用类来定义好管理test点,没有其他意思,大概就这样,没写完全:
typedef class person
{
public:
long int num;
char name[20];
char sex;
float scpre;
per test;
person &operator=(person &a)
{
//这里你自己写代码
};}Stud;
不明白此句的意思???麻烦解释一下???