//i need the explanation of the below c++ code in 30 minutes. #include using namespace std; class University //class (University) definition { // encapsulation private: static string Name,location; //Static variables declaration public: static void getdata() //Static function definition { cout<<"Please Enter Name of University : "; getline(cin,Name); Check: if(Name=="CITY UNIVERSITY"||Name=="city university") //input validation { cout<<"Please Enter Location of University : "; getline(cin,location); Chec: if(location=="DALAZAK ROAD PESHAWAR"||location=="dalazak road peshawar") { } else { for(bool itrue=false;itrue=true;itrue++) { cout<<"Please Enter Valid location of University : "; getline(cin,location); goto Chec; } } } else { for(bool istrue=false;istrue=true;istrue++) { cout<<"Please Enter Valid Name of University : "; getline(cin,Name); goto Check; } } } static void Display() // another static function definition { cout<<"University Name is : "<>age; cin.ignore(); cout<<"Please Enter Your Gender : "; getline(cin,Gender); cout<<"Please Enter Your Department : "; getline(cin,Department); } virtual void display() // Late binding { cout<<"Your Name is : "<Level=Level; this->Semester=Semester; } void getdata() // definition of member function { University::getdata(); person::getdata(); cout<<"Please Enter Your Education Level : "; getline(cin,Semester); cout<<"Please Enter Your Semester Number : "; getline(cin,Level); } void display() // defintion of member function { University::Display(); person::display(); cout<<"Education Level is : "<salary=salary; } void display() //member function definition { University::Display(); person::display(); cout<<"Specialization Subject is : "<getdata(); cout<<"\t.............................."<display(); cout<>sa; e.getdata(sa); cout<<"\t.............................."<
//i need the explanation of the below c++ code in 30 minutes.
#include<iostream>
using namespace std;
class University //class (University) definition
{
// encapsulation
private:
static string Name,location; //Static variables declaration
public:
static void getdata() //Static function definition
{
cout<<"Please Enter Name of University : ";
getline(cin,Name);
Check:
if(Name=="CITY UNIVERSITY"||Name=="city university") //input validation
{
cout<<"Please Enter Location of University : ";
getline(cin,location);
Chec:
if(location=="DALAZAK ROAD PESHAWAR"||location=="dalazak road peshawar")
{
}
else
{
for(bool itrue=false;itrue=true;itrue++)
{
cout<<"Please Enter Valid location of University : ";
getline(cin,location);
goto Chec;
}
}
}
else
{
for(bool istrue=false;istrue=true;istrue++)
{
cout<<"Please Enter Valid Name of University : ";
getline(cin,Name);
goto Check;
}
}
}
static void Display() // another static function definition
{
cout<<"University Name is : "<<Name<<endl;
cout<<"Location is : "<<location<<endl;
}
};
// static variables initialization
string University::Name="";
string University ::location="";
class person // class (person) definition
{
private:
string Name,Gender,Department; //variables
int age; //declaration
public:
virtual void getdata() // Late binding
{
cout<<"Please Enter Your Name : ";
getline(cin,Name);
cout<<"Please Enter Your age : ";
cin>>age;
cin.ignore();
cout<<"Please Enter Your Gender : ";
getline(cin,Gender);
cout<<"Please Enter Your Department : ";
getline(cin,Department);
}
virtual void display() // Late binding
{
cout<<"Your Name is : "<<Name<<endl;
cout<<"Your age is : "<<age<<endl;
cout<<"Your Gender is : "<<Gender<<endl;
cout<<"Your Department is : "<<Department<<endl;
}
};
class student: public person, public University // (student child_class definition) it derived from two base classes
// so it is called multiple inheritance
{
private:
string Level,Semester; // data members declaration
public:
student() // default constructor
{
}
student(string Level,string Semester) // parameterized constructor
{
this->Level=Level;
this->Semester=Semester;
}
void getdata() // definition of member function
{
University::getdata();
person::getdata();
cout<<"Please Enter Your Education Level : ";
getline(cin,Semester);
cout<<"Please Enter Your Semester Number : ";
getline(cin,Level);
}
void display() // defintion of member function
{
University::Display();
person::display();
cout<<"Education Level is : "<<Semester<<endl;
cout<<"Semester Number is : "<<Level<<endl;
}
};
class teachers: public person, public University // definition of (teacher Child_Class) it derived from two
// base classes so its called multiple inheritance.
{
private:
// data members declaration
int salary;
string specialization;
public:
//polymorphism
void getdata() // member function definition
{
University::getdata();
person::getdata();
cout<<"Please Enter Your Specialization Subject : ";
getline(cin,specialization);
}
void getdata(int salary)
{
this->salary=salary;
}
void display() //member function definition
{
University::Display();
person::display();
cout<<"Specialization Subject is : "<<specialization<<endl;
cout<<"Sallary is : "<<salary<<endl;
}
};
int main()
{
person *p = new student;
student s("","");
teachers e;
cout<<"\t======================"<<endl;
cout<<"\t= Student Enter Data ="<<endl;
cout<<"\t======================"<<endl<<endl;
p->getdata();
cout<<"\t.............................."<<endl;
cout<<"\t. Displaying data of Student ."<<endl;
cout<<"\t.............................."<<endl<<endl;
p->display();
cout<<endl<<"\t======================"<<endl;
cout<<"\t= Teacher Enter Data ="<<endl;
cout<<"\t======================"<<endl<<endl;
e.getdata();
int sa;
cout<<"Please Enter Your Salary : ";
cin>>sa;
e.getdata(sa);
cout<<"\t.............................."<<endl;
cout<<"\t. Displaying data of Teacher ."<<endl;
cout<<"\t.............................."<<endl<<endl;
e.display();
return 0;
}
Step by step
Solved in 3 steps with 1 images