If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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)’

Re: Problem with composition

Originally Posted by depecheSoul

int main()
{ addition add(numbers); cout<<add.rezultat()<<endl;
}

The bold line declares a function called 'add' that takes a numbers object as argument and returns an addition object. If you want to create a variable called add of type addition that is instantiated with a default constructed numbers object, I think you can do this:

Code:

int main()
{
addition add(numbers());
}

That said, I don't see the point of having a class that can only contain undefined values.

Cheers, D Drmmr

Please put [code][/code] tags around your code to preserve indentation and make it more readable.

As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Is your question related to IO?
Read this C++ FAQ LITE article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.