Q:

Assume we have a class named NoDefault that has a constructor that takes an int, but has no default constructor. Define a class C that has a member of type NoDefault. Define the default constructor for C

0

Assume we have a class named NoDefault that has a constructor that takes an int, but has no default constructor. Define a class C that has a member of type NoDefault. Define the default constructor for C.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class NoDefault {
public:
  NoDefault(int i) : i_(i) {}
private:
  int i_;
};

class C {
public:
  C() : nd(0) {}

private:
  NoDefault nd;
};

int main() {
  C c;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now