请大家帮忙,编了好几个小时了,都不行,
求高人帮忙,编译老出现cannot access private member declared in class 'student'和see declaration of 'studentnumber'我用对象指针也不能访问私有成员啊
对象指针要等对象赋了值才可以指向对象吗?
class student
{
private:
int studentnumber;
char name[30];
char studentday[30];
char class1[30];
char p[30];//专业
public:
student();
student(int x,char a[],char b[],char c[],char d[]);
virtual ~student();
void SetInfo();
void Show();
};
#include "student.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#include <string.h>
#include<iostream.h>
student::student()
{
}
student::student(int x,char a[],char b[],char c[],char d[])
{
studentnumber=x;
strcpy(a,name);
strcpy(b,class1);
strcpy(c,studentday);
strcpy(d,p);
}
student::~student()
{
}
void student::SetInfo()
{
cout << "ad";
}
void student::Show()
{
cout << name <<endl << class1 <<endl <<p<<endl<<studentday<<endl<<studentnumber<<endl;
}
int main()
{
student A[20],*p;
int secondnum;
int b;
int i=0;
char c[20],d[20],e[20],f[20];
cout<<" -学生信息管理系统-"<<endl<<endl;
cout<<"1----学生基本信息录入 2----学生信息查询"<<endl;
cout<<"3----学生信息修改 ";
cout<<"0----退出"<<endl;
cin >> secondnum ;cout <<endl;
switch(secondnum)
{
case 0:return 0;break;
case 1:
{
cout <<"请输入学号:";
cin>>b ;
cout<<endl<<"请输入姓名: ";
cin>> c[20];
cout <<endl;
cout <<"请输入班级: ";
cin >>d[20];
cout <<endl;
cout << "请输入出生年月: ";
cin >>e[20];
cout <<endl;
cout <<"请输入专业:";
cin>>f[20];
cout <<endl;
A[i].student::student(b,c,d,e,f);
p=A;
i++;
};break;
case 2:
{
int number2;
int n=0;
cout <<"请输入学生学号:"<<endl;
cin>> number2;
while(number2==p->studentnumber)
{
p++;
}
A[n].Show();break;
}
case 3:
{
A[1].SetInfo();
};break;
default: cout << "wrong";break;
}
return 0;
}