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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
#include<iostream.h>
#include<string.h>
#include<conio.h>
class STUDENT
{
protected :
char *name;
int age;
public :
STUDENT()
{
name=new char[strlen("No Name")];
strcpy(name,"NO Name");
age=5;
}
STUDENT(char *str,int no)
{
name=new char(strlen(str));
strcpy(name,str);
age=no;
}
virtual void getDetails()
{
cout<<"Name : "<<name<<"\nAge : "<<age;
}
virtual char * getName()
{
return name;
}
virtual int getAge()
{
return age;
}
};
class SSC : virtual public STUDENT
{
protected :
int ssc_marks;
public :
SSC() : STUDENT()
{
ssc_marks=1;
}
SSC(char * str, int n1, int n2) : STUDENT(str,n1)
{
ssc_marks=n2;
}
void getDetails()
{
STUDENT :: getDetails();
cout<<"\nSSC Marks : "<<ssc_marks;
}
int getSSCMarks()
{
return ssc_marks;
}
};
class HSC : virtual public SSC
{
protected :
int hsc_marks;
public :
HSC() : SSC()
{
hsc_marks=1;
}
HSC(char * str, int n1, int n2, int n3) : SSC(str,n1,n2)
{
hsc_marks=n3;
}
void getDetails()
{
SSC :: getDetails();
cout<<"\nHSC Marks : "<<hsc_marks;
}
int getHSCMarks()
{
return hsc_marks;
}
};
class CET : virtual public SSC
{
protected :
int cet_marks;
public :
CET() : SSC()
{
cet_marks=1;
}
CET(char * str, int n1, int n2, int n3) : SSC(str,n1,n2)
{
cet_marks=n3;
}
void getDetails()
{
SSC :: getDetails();
cout<<"\nCET Marks : "<<cet_marks;
}
int getCETMarks()
{
return cet_marks;
}
};
class ENGINEERING : public HSC, public CET
{
protected :
double cpi;
public :
ENGINEERING() : HSC(),CET()
{
cpi=1.0;
}
ENGINEERING(char * str, int n1, int n2, int n3, int n4, double n5) : HSC(str,n1,n2,n3), CET(str,n1,n2,n4)
{
cpi=n5;
}
void getDetails()
{
HSC :: getDetails();
cout<<"\nCET Marks : "<<CET :: getCETMarks()<<"\nCPI : "<<cpi;
}
int getCPI()
{
return cpi;
}
};
int main()
{
clrscr();
ENGINEERING s2("gaurav",19,85,72,135,8.5);
s2.getDetails();
getch();
return 0;
}
|