Inheritance in C++ || Multilevel Inheritance && Multiple Inheritance || Inheritance Access

preview_player
Показать описание
#learncplusplus
#learnprogrammingonyoutube
#oopsconcepts
Рекомендации по теме
Комментарии
Автор

These are the practice questions related to inheritance sir..


1)
#include <iostream>
using namespace std;
class Parent{
public:
int
void getFatherDetails(){
cout<<"Father"<<assets;
}
};
class stud{
public:
string edu="MCA";
void getstudentDetails(){
cout<<edu<<"\n";
}
};
int main(){
stud s1;
s1.getstudentDetails();
}

2)
#include <iostream>
using namespace std;
class Parent{
public:
int
void getFatherDetails(){
cout<<"Father"<<assets;
}
};
class stud{
public:
string edu="MCA";
void getstudentDetails(){
cout<<edu<<"\n";
}
};
int main(){
stud s1;
s1.getstudentDetails();
s1.getFatherDetails();//error gives
}

3)
#include <iostream>
using namespace std;
class Parent{
public:
int
void getFatherDetails(){
cout<<"Father"<<" "<<assets;
}
};
class stud:public Parent{
public:
string edu="MCA";
void getstudentDetails(){
cout<<edu<<"\n";
}
};
int main(){
stud s1;
s1.getstudentDetails();
s1.getFatherDetails();
}

4)
#include <iostream>
using namespace std;
class Parent{
public:
int
void getFatherDetails(){
cout<<"Father"<<" "<<assets;
}
};
class stud:public Parent{
public:
string edu="MCA";
void getstudentDetails(){
cout<<edu<<"\n";
}
};
int main(){
stud s1;
s1.getstudentDetails();
s1.getFatherDetails();
cout<<s1.edu<<"\n";
}

5)
#include <iostream>
using namespace std;
class Father{
public:
int bankb=1234567;
};
class student{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

6)
#include <iostream>
using namespace std;
class Father{
public:
int bankb=1234567;
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<bankb<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

7)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<bankb<<"\n";//error because of private
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

8)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

9)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
Father f1;
cout<<f1.bankb<<"\n";//error bank is private
}

10)
#include <iostream>
using namespace std;
class Father{
protected:
int bankb=1234567;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
Father f1;
protected ie same as a private not access
}

11)
#include <iostream>
using namespace std;
class Father{
protected:
int bankb=1234567;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<bankb<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

12)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

13)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
protected:
int money=10000;
public:
string name;
student(string sname){
name=sname;
}
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";//within the class also not able to access the protected variable ie money
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

14)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
protected:
int money=60000;
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";
}
};
int main(){
student s1("karam");
s1.getStudentDetails();
}

15)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
protected:
int money=10000;
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";
}
};
int main(){
student s1("karam");//public so accessible
cout<<s1.name<<"\n";
}

16)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
protected:
int money=10000;
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";
}
};
int main(){
student s1("karam");//public so accessible
cout<<s1.name<<"\n";
cout<<s1.money<<"\n";//gives error because of protected
}

17)
#include <iostream>
using namespace std;
class Father{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
protected:
int money=10000;
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";
}
};
class gchild:public student{

};
int main(){
student s1("karam");//public so accessible
cout<<s1.name<<"\n";
cout<<s1.money<<"\n";
}
***MULTI-LEVEL***

18)
#include <iostream>
using namespace std;
class GrandFather{
public:
string assets="10 acres,
};
class Father:public GrandFather{
private:
int bankb=1234567;
protected:
int pocketmoney=8500;
public:
string veh="car && bike";
};
class student:public Father{
public:
string name;
student(string sname){
name=sname;
}
protected:
int money=10000;
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<veh<<"\n";
cout<<pocketmoney<<"\n";
cout<<money<<"\n";
cout<<assets<<"\n";
}
};
int main(){
student s1("karam");//public so accessible
s1.getStudentDetails();
}
***MULTIPLE INHERITANCE***

19)
#include <iostream>
using namespace std;
class nanaamma{
public:
string assets="10 acres";
};
class ammaamma{
public:
int
};
class student:public nanaamma, public ammaamma{
public:
string name;
student(string sname){
name=sname;
}
public:
void getStudentDetails(){
cout<<name<<"\n";
cout<<money<<"\n";
cout<<assets<<"\n";
}
};
int main(){
student s1("karam");//public so accessible
s1.getStudentDetails();
}

rekhaharikaharshita
Автор

Sir I completed the full c++ concepts by yesterday afternoon.But I was unable to post the comments that I completed this video sir or To send the practice questions through comments sir..
Whenever I was trying to send the comments showing that you will be able to send the comments after 25 hours like that sir ....
I completed the c++ recordings yesterday and I will submit the practice questions now through comment section sir..
From yesterday I started reading documentation of c and c++ in w3 schools and prepared the notes what I felt something new concept to me sir...
And also I practiced 13 oops concepts questions available in the practice example section of w3 schools sir. I will submit that questions also here sir..I felt very happy because I solved all the oops concepts questions by own without taking help sir.I am a new to oops concepts but after listening your recording and also solved some questions related to oops concepts, I got confidence towards programming language sir.now I am starting watching icubecide sir that will complete within 2 days sir..I know html and css but I want to follow whatever you said to the super 60 members.. although I am good at HTML, css, I want to see the icube code css, html, and related projects.. I will complete those works within 3 days sir...

rekhaharikaharshita
Автор

Sir I completed the html and css playlist in the icube code sir.Will I have to read the documentation and make notes of html and css in the w3 schools website or not sir.

rekhaharikaharshita
Автор

Sir nenu mee classes vintunnanu. Nenu non -it lo job chesthunnanu. It ki shift avudam ani anukuntunnanu. Meeku meil ki doubts adigedi nene sir. Naaku morning 7 to evening 8 daka work untundi. Naaku konchem time isthe nenu total nerchesukunta. So... Pls nannu elagaina superr 60 loki join chesukovadaniki okka avakasam ivvandi sir. Nenu ippudu ifelse topic lo unna sir.

talarirajkumar
visit shbcf.ru