1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include<iostream>
using namespace std;
class wasim
{
int x,y;
public:
int addition(int a,int b,int c); //this declares a member function
wasim(x,y); //this declares the constructor.
};
wasim::waism(x,y)
{
cout<<x<<y; //this statement executes when you create a wasim.
}
int wasim::addition(int a,int b,int b)
{
int z;
return (a+b+c);
}
int main()
{
wasim masih(1,2,3); //this doesn't work, your constructor takes only two params
wasim tukhi(1,2); //this works and makes a wasim on the stack.
//cout<<tukhi.wasim(1,2)<<masih.addition(1,2,3); //this line is just weird.
cout<<tukhi.x<<tukhi.y<<masih.addition(1,2,3); //this might be what you want.
return 0;
}
|