Jun 20, 2013 at 1:58pm Jun 20, 2013 at 1:58pm UTC
i need help how can i show the information tha entered and how can i access the classes i have created in the main function. . .
here is my code
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
#include <iostream>
using namespace std;
const in LEN = 80;
////////////////////////////////////////////////////
class student
{
private :
long int idno;
char surname[LEN];
string name[LEN];
public :
void getdata(){
cout << "Enter IDno. \n " ; cin >> idno;
cout << "Enter Surname \n" ; cin >> surname;
cout <<"Enter Name \n " ; cin >> name;
}
void dispaly(){
cout << "\n IDno. : " << idno;
cout << "\n Surname : " << surname;
cout << "\n Name : " << name ;
}
};
/////////////////////////////////////////////////////
class lecture: public student //lecture class
{
private :
char title;
char surname[LEN];
public :
void getdata(){
student::getdata()
cout << "Enter title: " ; cin >> title;
cout << "Enter surname: " ; cin >> surname;
}
void display(){
student::dispaly()
cout << "\n Title: " << title << ". " << surname;
}
}
//////////////////////////////////////////////////////////
int main()
{
}
Last edited on Jun 21, 2013 at 10:12am Jun 21, 2013 at 10:12am UTC
Jun 20, 2013 at 2:36pm Jun 20, 2013 at 2:36pm UTC
Please use code tags so that your code appears properly formatted, so that the people who might be able to help you can read it clearly.
Why is lecture inheriting from student ? That doesn't seem like an "is-a" relationship to me?
Jun 20, 2013 at 7:54pm Jun 20, 2013 at 7:54pm UTC
If Lecture pertains to a lecture class then a Lecture should contain a Student or more specifically, a container of Students.
No inheritance is needed.
Last edited on Jun 20, 2013 at 7:56pm Jun 20, 2013 at 7:56pm UTC
Jun 21, 2013 at 1:35pm Jun 21, 2013 at 1:35pm UTC
Your inheritance still makes no sense. Is a lecturer a type of school? Is a student a type of school?
I think you need to go back to your textbook and read up on what inheritance is actually for .
Jun 21, 2013 at 2:31pm Jun 21, 2013 at 2:31pm UTC
@freemanl
There are 3 types of relationships:
1. "IS A" implies inheritance.
2. "HAS A" means a member variable has the type of another class.
3. "USES A" means a variable of another type of class is a parameter / argument to a member function.
Note that one doesn't have to fit everything into an inheritance tree.
As MikeyBoy says, read all about it.
HTH
Jun 25, 2013 at 9:32am Jun 25, 2013 at 9:32am UTC
thanks a lot didn't know . .. ..