//现实的时候看出来只有 _stu_id显示出来了,后面都是些乱码,怎么改?
#include"iostream"
using namespace std;
class CStu
{
public:
int _stu_id;
string _name;
double _grade1;
double _grade2;
double _grade3;
double _grade4;
CStu(){}
CStu(int id,string name,double grade1,double grade2,double grade3,double grade4)
{
_stu_id=id+1;
_name=name;
_grade1=grade1;
_grade2=grade2;
_grade3=grade3;
_grade4=grade4;
}
};
int main()
{
CStu *stu[4];
stu[0]=new CStu(0,"甲",30,45,50,45);
stu[1]=new CStu(1,"乙",34,67,2,123);
stu[2]=new CStu(2,"丙",34,2,3,0.3);
stu[3]=new CStu(3,"丁",98,57,92,7);
int i;
for(i=0;i<4;i++)
{
printf("%d%-10s%-4lf%-4lf%-4lf%-4lf\n",stu[i]->_stu_id,stu[i]->_name,stu[i]->_grade1,stu[i]->_grade2,stu[i]->_grade3,stu[i]->_grade4);
}
getchar();
return 0;
}
#include"iostream"
using namespace std;
class CStu
{
public:
int _stu_id;
string _name;
double _grade1;
double _grade2;
double _grade3;
double _grade4;
CStu(){}
CStu(int id,string name,double grade1,double grade2,double grade3,double grade4)
{
_stu_id=id+1;
_name=name;
_grade1=grade1;
_grade2=grade2;
_grade3=grade3;
_grade4=grade4;
}
};
int main()
{
CStu *stu[4];
stu[0]=new CStu(0,"甲",30,45,50,45);
stu[1]=new CStu(1,"乙",34,67,2,123);
stu[2]=new CStu(2,"丙",34,2,3,0.3);
stu[3]=new CStu(3,"丁",98,57,92,7);
int i;
for(i=0;i<4;i++)
{
printf("%d%-10s%-4lf%-4lf%-4lf%-4lf\n",stu[i]->_stu_id,stu[i]->_name,stu[i]->_grade1,stu[i]->_grade2,stu[i]->_grade3,stu[i]->_grade4);
}
getchar();
return 0;
}