C++ examples for Class:Member Field
Initializing Class Member Variables
#include <cinttypes> #include <iostream> using namespace std; class Car/* w w w. jav a2 s .c o m*/ { private: int m_NumberOfWheels{}; public: int GetNumberOfWheels() { return m_NumberOfWheels; } }; int main(int argc, char* argv[]) { Car myCar; cout << "Number of wheels: " << myCar.GetNumberOfWheels() << endl; Car myMotorcycle; cout << "Number of wheels: " << myMotorcycle.GetNumberOfWheels() << endl; return 0; }