What is the output of the following C program?
[gamipress_button type=”submit” label=”Run Code Online” onclick=”window.open(‘https://coderseditor.com’,’_blank’)”]
#include <iostream> using namespace std; class X { private: static const int a = 76; public: static int getA() { return a; } }; int main() { cout <<X::getA()<<endl; return 0; }
Studently Answered question October 11, 2022
Output: The program compiles and prints 76
The initialization of data members in C++ class declarations is typically not permitted, but static const integral members are handled differently and may be initialised with the declaration.
Studently Answered question October 11, 2022