0% found this document useful (0 votes)
12 views1 page

Code TP3 CPP 24 - 25

Uploaded by

bedairiainel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Code TP3 CPP 24 - 25

Uploaded by

bedairiainel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

using namespace std;

class room
{private:
float length, width, height;
public:
// void initdata(float l, float w, float h)
// { cout<<"initialization "<<endl;
// length=l; width=w; height=h;}
room (float l, float w, float h): // This is the constructor
length(l),width(w),height(h)
{cout<<"I am the constructor"<<endl;}
float area()
{cout<<"the area is: "<<length*width<<endl;}
float volume()
{cout<<"the volume is: "<<length*width*height<<endl;}
};

int main()
{ room room1(3,3,3); // working with the constructor
//room1.length=2;room1.width=2;room1.height=2;// direct access to the
// attributes if they were public
// room1.initdata(3,3,3); // working with the initdata method
room1.area();
room1.volume();
return 0;
}

You might also like