主题:新手上路
#include <iostream>
using namespace std;
class student
{
private :
int num;
int grade;
public:
student(int n=2,int g=4):num(n),grade(g){}
void show()
{cout<<num<<grade<<endl;}
};
int main()
{
student stu[5]={
student(1,2),
student(4,2),
student(1,4),
student(41,2),
student(1,55)
};
student *p;
*p=stu[0];
p->show();
return 0;
}
请教大家啊,,这个程序没有错误,可为什么运行起来是空的结果,,而不是输出stu[0]的数组呢????
using namespace std;
class student
{
private :
int num;
int grade;
public:
student(int n=2,int g=4):num(n),grade(g){}
void show()
{cout<<num<<grade<<endl;}
};
int main()
{
student stu[5]={
student(1,2),
student(4,2),
student(1,4),
student(41,2),
student(1,55)
};
student *p;
*p=stu[0];
p->show();
return 0;
}
请教大家啊,,这个程序没有错误,可为什么运行起来是空的结果,,而不是输出stu[0]的数组呢????