//Skip to content
Inheritance With Base Class Parameterized Constructor in C++
- #include<iostream>
- using namespace std;
-
- class Area
- {
- private:
- int length;
- int width;
- public:
- Area(int a,int b){
- length=a;
- width=b;
- }
- int getArea(){
- return length*width;
- }
- };
-
- class Volume:public Area
- {
- private:
- int height;
- public:
- Volume(int a,int b,int c):Area(a,b){
- height=c;
- }
- void getVolume(){
- cout<<"Volume : "<<height*getArea()<<endl;
- }
- };
-
-
- int main()
- {
- Volume volume(3,5,7);
- volume.getVolume();
- return 0;
- }
I am Md Abdullah Al Hasan. I have completed my graduation in Computer Science and Engineering from Jashore University of Science and Technology.
0 Comments:
Post a Comment