What independent changes will allow the code to work correctly?
class Counter {
  public: // 1
    void Count(); // 2
};

int main() {
  Counter obj;
  obj.Count();
  return 0;
}

// 3
Explanation
Let's consider all options one by one:
  • code couldn't compile without changes: obj.Count() calls function that doesn't have definition
  • changing private to public in line 1 wouldn't solve problems described above, but also we can't call private member of class
  • add code in line 3 also wouldn't solve first problem, class method still doesn't have definition

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes