top of page

example of class in oops c++ programming

#include <iostream.h>


class Rect

{

public:

double length;

double breadth;

double calculateArea()

{

return length*breadth;

}

};



int main()

{

Rect obj;

obj.length=10.5;

obj.breadth=20.5;

cout<<"The Area of Rectangle is :"<<obj.calculateArea()<<endl;


return 0;

}



7 views0 comments

Recent Posts

See All

Object and Class in C++ Programming

Object and Class in C++ Programming In this program, we have used the Room class and its object room1 to calculate the area and volume

Comments


bottom of page