Multiple choice technology programming languages

class A { const int k; public: void fun() { cout<

  1. k will display garbage values

  2. k will print 0, as default constructor is called.

  3. Error as no constructor is defined.

  4. Error, as main should precede with int and should return 0.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Const data members must be initialized either via an initializer list in the constructor or with in-class initialization (C++11 and later). Since class A has no constructor and const member k is not initialized at declaration, the code fails to compile.