What will be printed out as a result of the following code execution?
#include "stdio.h"

class Counter {
  public:
    void Count() { printf("%d", 1); }
};

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

void Counter::Count() { printf("%d", 2); }
Explanation
The function Counter::Count belongs to the class, and therefore an error will be thrown about redefining the function.

Follow CodeGalaxy

Mobile Beta

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