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

Comments


bottom of page