'C++ initalize class values after constructor

I have a class like this:

class test{
private:
    anotherClass _someVar;
public:

    test(){}; 

    void load() {
        anotherClass _someVar = anotherClass(.....);
    }
};

But this keeps getting the error no default constructor exists for class "anotherClass". But if I move the function load() into the constrcutor I also get the same error.

class test{
private:
    anotherClass _someVar;
public:

    test(){
        anotherClass _someVar = anotherClass(.....);
    }; 

};

Lastly, if this is illegal in c++, is there a way I can generate a class variable within a function of that class that can be shared to other functions of that same class? For that specific instance that is.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source