#include <iostream>
usingnamespace std;
class First{
public:
int a;
int b;
public:
First(int c,int d):a(c), b(d){};
int sum(){ return (a+b); }
};
int mmm(int x, int y) {
int z=x+y;
return z;
}
int main(){
First sum1(2,3);
First sum2(4,5);
cout<<sum1.sum()<<endl;
cout<<sum2.sum()<<endl;
int r;
r = mmm(sum1.a, sum1.b);
cout<< r <<endl;
return 0;
}
Of course you can have a function, like the mmm, that returns the sum of its arguments, but what does that have to do with First? The members of First are the interface of First and determine how other code can/must interact with type First objects.