Professional Documents
Culture Documents
a+b*c
# include<iostream.h>
# include<conio.h>
class count{
private:
int n;
public:
count()
n=0;
void show ()
cout<<"n="<<n<<endl;
n=n+1;
};
void main()
clrscr();
count obj;
obj.show();
++obj;
obj.show();
getch();
# include<iostream.h>
# include<conio.h>
class count
private:
int n;
public:
count()
n=0;
void show ()
cout<<"n="<<n<<endl;
count temp;
n=n+1;
temp.n=n;
return temp;
};
void main()
clrscr();
count x, y;
x.show();
y.show();
y=++x;
x.show();
y.show();
getch()
OUTPUT:
N=0 N=1
N=0 N=1
# include<iostream.h>
# include<conio.h>
class count
{
private:
int n;
public:
count()
n=0;
void show ()
cout<<"n="<<n<<endl;
count temp;
n=n+1;
temp.n=n;
return temp;
};
void main()
clrscr();
count x;
x.show();
++x;
x++;
x.show();
getch();
# include<iostream.h>
# include<conio.h>
class add
{
private:
int a,b;
public:
add()
a=b=0;
void in()
cout<<"enter a:";
cin>>a;
cout<<"enter b:";
cin>>b;
void show()
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
add temp;
temp.a=p.a+a;
temp.b=p.b+b;
return temp;
};
void main()
add x,y,z;
x.in();
y.in();
z=x+y;
x.show();
y.show();
z.show();
getch();
OUTPUT:
Enter a: 5
Enter b: 6
Enter a: 8
Enter b: 9
A=5
B=6
A=8
B=9
A=13
B=15
# include<iostream.h>
# include<conio.h>
# include<string.h>
# include<stdio.h>
class string
private:
char str[50];
public:
string()
str[0]='\0';
void in()
cout<<"enter string:";
gets(str);
void show()
{cout<<str<<endl;
}
string operator = (string s)
string temp;
strcpy(temp.str,str);
strcat(temp.str,s.str);
return temp;
};
void main()
string s1,s2,s3;
s1.in();
s2.in();
cout<<"s1=";
s1.show();
cout<<"s2=";
s2.show();
cout<<"s3=";
s3.show();
s3 = s1+s2;
cout<<"s3=";
s3.show();
getch();
OUTPUT:
s1= sohaob
s2= jamil
s3= sohaibjamil