C++ examples for Class:Member Field
Adding a Second Object
#include <cinttypes> #include <iostream> using namespace std; class Car//from w w w . j av a 2 s . c o m { public: int m_NumberOfWheels; }; int main(int argc, char* argv[]) { Car myCar; myCar.m_NumberOfWheels = 4; cout << "Number of wheels: " << myCar.m_NumberOfWheels << endl; Car myMotorcycle; myMotorcycle.m_NumberOfWheels = 2; cout << "Number of wheels: " << myMotorcycle.m_NumberOfWheels << endl; return 0; }