C++ Tutorial for Beginners 32 - C++ Inheritance

preview_player
Показать описание
c++ inheritance constructor
c++ inheritance virtual
c++ inheritance private
c++ inheritance override
c++ inheritance multiple
c++ inheritance public
c++ inheritance destructor
c++ friend inheritance
Рекомендации по теме
Комментарии
Автор

this channel is very useful to me . i learnt c++ n java from here and i got so many knowledge, and also i suggest this channel to my friend . thanks for making those tutorials .

deepjitdas
Автор

Very well explicated!Thank you very much.

Glauberz
Автор

Why used std::cout here....why not cout alone

anuragsharma
Автор

video is really quiet. cant hear what you are saying unfortunately

sophiewhiteside
Автор

sir i am getting garbage value some 168425678, -965335677 in output for both areas
#include <iostream>
using namespace std;

class Shape {
protected:
int width, height ;
public:
val( int a, int b) {
width = a;
height = b;
}


};

class Rectangle: public Shape {
public:

int area () {
cout << "Rectangle class area :" <<endl;
return (width * height);
}
};

class Triangle: public Shape{
public:

int area () {
cout << "Triangle class area :" <<endl;
return (width * height / 2);
}
};

// Main function for the program
int main( ) {

Rectangle rec;
Triangle tri;

// store the address of Rectangle
Shape shape1;
shape1.val(10, 2);


cout<<rec.area()<<endl;
cout<<tri.area()<<endl;

return 0;
}

Ram-Deep