What will be the result of the program?
#include <iostream>

class Clazz {
   int Anton;
   int Kris;
   int Denis;

   Clazz(int a)
      : Anton(++a)
      , Denis(++a)
      , Kris(++a)

int main(int argc, char *argv[]) {
   static int a;
   Clazz x(a);
   std::cout << x.Anton << x.Denis << x.Kris;
1. Static variables are always initialized with zero by default.
2. Class fields are initialized in the order of their declaration in the class code, not in the order of constructors declaration.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes