Lines 12-13,22,26: get() and out() are not typed.
Lines 17-18, 30,35: getdata() and outdata() are not typed.
Line 21,44: You can't use status because status is a private subclass of Student.
Line 22: student has no function called get().
Line 24: Statements should be separated by a ;
Line 24,28,32,33,37,38: You're inputting/outputting the global, not the instance data.
Line 26: Ditto regarding out().
Line 20,21: Why are these global? You declare st and s as arrays at line 43-44.
Line 42: n is uninitialized.
Line 45,50: The termination condition of your loop results in undefined behavior because n is uninitialized.
Line 21,44: Why are you declaring s here? status is only declared within student. student should contain an instance of status.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include<iostream>
using namespace std;
class student
{
char name[80];
int roll;
class status
{ char ch;
public:
void get();
void out();
};
public:
status s;
void getdata();
void outdata();
};
void student::status::get()
{ cout<<"Alive or Dead(a/d)";
cin >> ch;
}
void student::status::out()
{ cout<<"Status-" << ch;
}
void student::getdata()
{ cout<<"Enter name";
cin.getline(name,80,'.');
cout<<"Enter roll no";
cin >> roll;
}
void student::outdata()
{ cout<<"Name-" << name<<endl;
cout<<"Roll no-" << roll<<endl;
}
int main()
{ int n,i;
student st[60];
cout << "How many students?";
cin >> n;
for(i=0;i<n;i++)
{ st[i].getdata();
st[i].s.get();
}
for(i=0;i<n;i++)
{ st[i].outdata();
st[i].s.out();
}
}
|