In this program, we are going to share a static data members in C++. If you are a beginner and want to start learning the C++ programming, then keep your close attention in this tutorial as I am going to share a program for static data members in C++ with the output.
To increase your Java knowledge, practice all C++ programs, here is a Collection of 100+ C++ problems with solutions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <iostream> using namespace std; class A { public: A() { cout << "A's Constructor Called " << endl; } }; class B { static A a; public: B() { cout << "B's Constructor Called " << endl; } }; int main() { B b; return 0; } |
B’s Constructor Called
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.