دوستان کسی می تونه بگه مشکل این کد کجاست
؟ و چطوری میشه از
2تا دانشجو به
10 دانشجو بیشترش کرد
؟ #include<iostream.h>
#include<conio.h>
#include<string.h>
class student
{
private:
char stdId[20];
char stdName[20];
int stdAge;
char stdProgram[20];
int noOfSubjects;
public:
student(char* stdId1,char *stdName1,int stdAge1,char *stdProgram1,intnoOfSubjects1)
{
strcpy(stdId,stdId1);
strcpy(stdName,stdName1);
stdAge=stdAge1;
strcpy(stdProgram,stdProgram1);
noOfSubjects=noOfSubjects1;
}
int setMember(char* stdId1,char *stdName1,int stdAge1,char *stdProgram1,intnoOfSubjects1)
{
strcpy(stdId,stdId1);
strcpy(stdName,stdName1);
stdAge=stdAge1;
strcpy(stdProgram,stdProgram1);
noOfSubjects=noOfSubjects1;
return 0;
}
int getMember(char*stdId1,char *stdName1,int *stdAge1,char *stdProgram1,int*noOfSubjects1)
{
strcpy(stdId1,stdId);
strcpy(stdName1,stdName);
*stdAge1=stdAge;
strcpy(stdProgram1,stdProgram);
*noOfSubjects1=noOfSubjects;
return 0;
}
int Display()
{
cout<<"stdId="<<stdId<<"\nstdName="<<stdName<<"\nstdAge="<<stdAge<<"\nstdProgram="<<stdProgram<<"\nnoOfSubjects"<<noOfSubjects<<"\n\n";
return 0;
}
friend void my_friend(studentstud);
~student()
{
}
};
void my_friend(student s)
{
if(s.noOfSubjects > 5)
cout<<"\nStudent has registered in morethan 5 subjects\n";
else
cout<<"\nStudent has not registered in morethan 5 subjects\n";
}
main()
{
char stdId[20];
char stdName[20];
int stdAge;
char stdProgram[20];
int noOfSubjects;
student *std_arr[100];
cout<<"Please enter data for student1\n";
cout<<"Student ID: ";
cin>>stdId;
cout<<"Student Name: ";
cin>>stdName;
cout<<"Student Age: ";
cin>>stdAge;
cout<<"Student Program: ";
cin>>stdProgram;
cout<<"Number of Subjects: ";
cin>>noOfSubjects;
std_arr[0]=new student(stdId,stdName,stdAge,stdProgram,noOfSubjects);
cout<<"Please enter data for student2\n";
cout<<"Student ID: ";
cin>>stdId;
cout<<"Student Name: ";
cin>>stdName;
cout<<"Student Age: ";
cin>>stdAge;
cout<<"Student Program: ";
cin>>stdProgram;
cout<<"Number of Subjects: ";
cin>>noOfSubjects;
std_arr[1]=new student(stdId,stdName,stdAge,stdProgram,noOfSubjects);
cout<<"\nRecord for Student1\n";
std_arr[0]->Display();
cout<<"\nRecord for Student2\n";
std_arr[1]->Display();
my_friend(*std_arr[0]);
my_friend(*std_arr[1]);
return 0;
}