|
-
December 20th, 2011, 11:40 AM
#1
Problem with composition
Hello. I have made this program for practice reasons but I dont know what i have done wrong can you please tell me.
I always get the same mistake: dinamicka_alokacija_memorije.cxx:25:12: error: request for member ‘rezultat’ in ‘add’, which is of non-class type ‘addition(numbers)’
This is the program:
#include <iostream>
using namespace std;
class numbers
{
private:
int x,y;
public:
int getx() {return x;}
int gety() {return y;}
};
class addition
{
private:
numbers num;
public:
addition(numbers obj):num(obj) {}
int rezultat() {return (num.getx()+num.gety());}
};
int main()
{
addition add(numbers);
cout<<add.rezultat()<<endl;
}
Thank you very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|