Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Class in a class (C++)

Name: Anonymous 2007-06-29 7:25 ID:gaE5eFHD

Lets say I have this following class:

class Settings {
public:
  Settings(char *filename);
  ~Settings();
protected:
  class Anotherclass anotherclass;
};


Upon the Constructor call 'Settings' it says error C2512: '' : no appropriate default constructor available. How do I get a class to be inside another class?

Name: Anonymous 2007-06-29 8:05 ID:/1oDRXbD

>>1

Your C2512 error has nothing to do with putting a class inside another class. As >>2 points out, either add a default constructor Settings(); or initialise using code like Settings *s = new Settings("the filename"); rather than Settings s;.

>>2

Using the class keyword in class Anotherclass anotherclass; not wrong, though it is redundant.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List