Sunday, January 1, 2012

Inline function in 'C++'.

Example



#include<conio.h>
#include<iostream.h>
#include<math.h>
class area
{
int l,b,c;
public:
void getdata()
{
cout<<"ENTER LENGTH AND BREADTH"<<endl;
cin>>l>>b;
}
inline void square()
{
c=4*l;
cout<<"AREA OF SQUARE:"<<c<<endl;
}
inline void rectangle()
{
cout<<"AREA OF RECTANGLE"<<l*b<<endl;
}
inline void triangle()
{
cout<<"AREA OF TRIRANGLE:"<<0.5*l*b<<endl;
}
};
int main()
{
area a;
clrscr();
a.getdata();
a.square();
a.rectangle();
a.triangle();
getch();
return 0;




}
/*===============================================================
OUTPUT
Enter length and breath::
4
3


AREA OF SQUARE IS:::16
AREA OF RECTANGLE IS:::12
AREA OF TRIANGLE IS:::6
*/

No comments:

Post a Comment