Write a C++ program to declare a class COLLEGE with members as college code. Derive a new class as STUDENT with members as studid. Accept and display details of student along with college for one object of student.
#include<iostream.h>
#include<conio.h>
class COLLEGE
{
protected:
int collegecode;
};
class STUDENT:public COLLEGE
{
int studid;
public:
void accept()
{
cout<<"Enter college code:";
cin>>collegecode;
cout<<"Enter student id";
cin>>studid;
}
void display()
{
cout<<"College code:"<<collegecode;
cout<<"Student id:"<<studid;
}
};
void main()
{
STUDENT s;
clrscr();
s.accept();
s.display();
getch();
}