does not have class type C++

c++

Solution

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.

Problem

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)->Scene::lake' does not have class type The source ``` class Scene { int L,Dist; Background back ; Lake lake(int L); IceSkater iceskater(int Dist); public : Scene(int L, int Dist) { cout<<"Scene was just created"<<endl; } ~Scene() { cout<<"Scene is about to be destroyed !"<<endl; } }; ```

Original source

Related problems