Docsity

Inheritance in c notes and details with programs.examples and data, Lecture notes of Computer Science

Toggle sidebar
bg1
C++ Hybrid Inheritance
Half breed legacy is a mix of more than one sort of legacy.
C++ Legacy
We should see a basic model:
#incorporate <iostream>
utilizing namespace sexually transmitted disease;
class A
{
secured:
int a;
public:
void get_a()
{
std::cout << "Enter the worth of 'a' : " << std::endl;
cin>>a;
}
};
class B : public A
{
secured:
int b;
pf3
pf4
pf5

Partial preview of the text

Download Inheritance in c notes and details with programs.examples and data and more Lecture notes Computer Science in PDF only on Docsity!

C++ Hybrid Inheritance

Half breed legacy is a mix of more than one sort of legacy.

C++ Legacy We should see a basic model:

#incorporate utilizing namespace sexually transmitted disease; class A { secured: int a; public: void get_a() { std::cout << "Enter the worth of 'a' : " << std::endl; cin>>a; } };

class B : public A { secured: int b;

public: void get_b() { std::cout << "Enter the worth of 'b' : " << std::endl; cin>>b; } }; class C { secured: int c; public: void get_c() { std::cout << "Enter the worth of c is : " << std::endl; cin>>c; } };

class D : public B, public C { secured: int d; public: void mul()

C++ Legacy Language structure of Various leveled legacy:

class A { // body of the class A. } class B : public A { // assortment of class B. } class C : public A { // assortment of class C. } class D : public A { // assortment of class D. } We should see a basic model:

#incorporate utilizing namespace sexually transmitted disease; class Shape//Announcement of base class. {

public: int a; int b; void get_data(int n,int m) { a= n; b = m; } }; class Square shape : public Shape//acquiring Shape class { public: int rect_area() { int result = ab; bring result back; } }; class Triangle : public Shape//acquiring Shape class { public: int triangle_area() { float result = 0.5a*b; bring result back;

Enter the base and level of the triangle: 2 5 Region of the triangle is : 5