This is one class from my program! When I\'m trying to compile the whole program, I get an error message like this:
main.cpp:174: error: \'((Scene*)this)
Your problem is in the following line:
Lake lake(int L);
If you're just trying to declare a Lake object then you probably want to remove the (int L). What you have there is declaring a function lake that returns a Lake and accepts an int as a parameter.
If you're trying to pass in L when constructing your lake object, then I think you want your code to look like this:
class Scene
{
int L,Dist;
Background back ;
Lake lake;
IceSkater iceskater;
public :
Scene(int L, int Dist) :
L(L),
Dist(Dist),
lake(L),
iceskater(Dist)
{
cout<<"Scene was just created"<<endl;
}
.....
Notice the 4 lines added to your constructor. This is called member initialization, and its how you construct member variables. Read more about it in this faq. Or some other tidbits I found here and here.
You've declared (but never defined) lake as a member function of Scene:
class Scene
{
// ...
Lake lake(int L);
But then in plot, you try to use lake as if it were a variable:
int plot()
{
lake.light_up();
Replace the line Lake lake(int L); with Lake lake= Lake(L);
or with this: Lake lake{L};
You declare lake as a method that takes one argument and returns a Lake. You then try and call a method on it via lake.light_up(). This causes the error you observe.
To solve the problem, you either need to declare lake to be a variable, e.g. Lake lake;, or you need to stop trying to call a method on it.