K
K
krembrule20162016-04-05 19:04:50
OOP
krembrule2016, 2016-04-05 19:04:50

How is a custom constructor inherited?

Hello!
I have a base class and its constructor:

class dom
{
public:
  dom(int h, string name);
  string n_Name;
  int height;
private:
};
dom::dom(int h, string name)
{
  n_Name = name;
  height = h;
  cout << "Constructor 1 in work" << endl;
};

I'm creating a derived class, and there's a misunderstanding here that doesn't clear up in the context of reading Dawson's book.
class skyskr : public dom
{
public:
  int kol_lud;
  void st(int h);
  skyskr();????
};

Which constructor should I define for a derived class? I know that constructors are not inherited - does that mean base class variables will be inherited but will be empty? I experimented in different ways: I defined the arguments of the derived class, like the constructor of the base class, and tried to write new ones - the studio swears.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-04-05
@krembrule2016

skyskr::skyskr()
: dom(1, "test")
{
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question