Professional Documents
Culture Documents
OOPFinal
OOPFinal
OOPFinal
#include <iostream>
#include<string>
using namespace std;
class publication
{
protected:
string title;
float price;
public:
publication()
{
title=" ";
price=0.0;
}
publication(string t,float p)
{
title=t;
price=p;
}
void getData(){
cout<<"Enter Title\n";
cin>>title;
cout<<"Enter Price\n";
cin>>price;
}
};
pagecount=pc;
}
void getData() {
publication :: getData();
cout<<"Enter Pagecount\n";
cin>>pagecount;
}
void putData()
{
cout<<"title : "<<title<<endl;
cout<<"Price : "<<price<<endl;
cout<<"Pagecount :"<<pagecount<<endl;
bool isOversize(){
if(pagecount > 800){
return true;
}
}
};
time=tim;
void putData()
{
cout<<"title : "<<title<<endl;
cout<<"Price : "<<price<<endl;
}
void getData() {
publication :: getData();
cout<<"Enter Time\n";
cin>>time;
}
bool isOversize(){
if(time > 90){
return true;
}
}
};
int main()
{
cout<<endl<<"Book data"<<endl;
book b;
b.getData();
b.putData();
cout<<endl;
if(b.isOversize()){
cout<<"Book is Oversized"<<endl;
}
cout<<endl;
Tape t;
t.getData();
t.putData();
cout<<endl;
if(t.isOversize()){
cout<<"Tape is Oversized";
}
return 0;
}
Q2
#include <iostream>
#include<string>
using namespace std;
class father
{
protected:
int age;
public:
father (int x)
{
age= x;
}
virtual void iam()
{
cout<<"I AM THE FATHER, my age is "<<age<<endl;
}
};
public:
daughter (int x) : father(x)
{
int main()
{
son s(13);
s.iam();
cout<<endl;
daughter d(24);
d.iam();
return 0;
}
Q4
#include<iostream>
using namespace std;
class Department
{
public:
int deptID;
string deptName;
Department(){}
Department(int id,string name)
{
deptID=id;
deptName=name;
}
void display()
{
cout<<"Department ID:"<<deptID<<endl;
cout<<"Department Name:"<<deptName<<endl;
}
};
class University
{
public:
string universityName;
string location;
Department dept;
};
class Laboratory
{
public:
int labID;
int experimentNo;
Laboratory(){}
Laboratory(int id,int no)
{
labID=id;
experimentNo=no;
}
};
class Person
{
public:
string name;
int age;
Person(){}
Person(string nm,int ag)
{
name=nm;
age=ag;
}
void display()
{
cout<<"Person name:"<<name<<endl;
cout<<"Person age:"<<age<<endl;
}
};
class Professor:public Person
{
public:
string profName;
Department dept;
Professor(){}
Professor(string n,Department d)
{
profName=n;
dept=d;
}
};
class Researcher:public Professor
{
public:
Laboratory lab;
Researcher(Laboratory l)
{
lab=l;
}
};
int main()
{
return 0;
}
Q6
Errors:-