This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<conio.h> | |
using namespace std; | |
class rectangle | |
{ | |
private: | |
int length; | |
int breadth; | |
public: | |
rectangle(); | |
rectangle(int ); | |
rectangle(int ,int ); | |
void area(); | |
} | |
; | |
rectangle::rectangle(int a,int b) | |
{ | |
length=a; | |
breadth=b; | |
cout<<"Constructor with two parameter called\n"; | |
} | |
void rectangle::area() | |
{ | |
int area=length*breadth; | |
cout<<"\nArea \t"<<area; | |
} | |
int main() | |
{ | |
int length,breadth; | |
cout<<"\nEnter length: \t"; | |
cin>>length; | |
cout<<"\nEnter breadth: \t"; | |
cin>>breadth; | |
rectangle r2(length,breadth); | |
r2.area(); | |
getch(); | |
return 0; | |
} | |
Comments
Post a Comment
Thanks for the comment and don't forget to subscribe.