Monday, May 9, 2016

Prove using two programs that inline functions sometimes increases and sometimes decreases the size of the executable code


#include<iostream.h>
#include<conio.h>
class extra
{
int n;
public:
extra()
{
n=0;
}
extra(int a)
{
n=a;
}
void assgn(int a);
void display();
};
inline void extra::assgn(int a)
{
n=a;
}
inline void extra:: display()
{
int i;
for(i=0;i<=n;i++)
{
cout<<"\n"<<i;

}
}
void main()
{
extra e;
int a;
clrscr();
cout<<"Enter value";
cin>>a;
e.assgn(a);
e.display();
getch();
}

No comments:

Post a Comment