You can imagine class a master plan or blue print of a car. It's just on paper, and it describes how the car should be created. The same model of cars can be created from a master plan but with different colors right? Just as a person have eyes, but your eyes might not be the same color as your cousins eye.
Example
Code:
#include <iostream>
#include <string>
using namespace std;
class Person
{
string m_name;
int m_strength;
int m_health;
public:
Person(string name) : m_name(name), m_strength(10), m_health(100)
{
cout << m_name << " is born." << endl;
}
void Exercise()
{
m_strength++;
m_health++;
}
void SmokeWeed()
{
m_strength--;
m_health-=5;
}
void Status()
{
cout << "\nName:\t\t" << m_name << "\nStrength:\t" << m_strength
<< "\nHealth:\t\t" << m_health << "\n\n";
}
virtual ~Person()
{
cout << m_name << " just died." << endl;
}
};
int main(int argc, char* args[])
{
Person bill("Bill Gates");
bill.Status();
bill.Exercise();
bill.Status();
bill.SmokeWeed();
bill.Status();
return 0;
}
Here the person have a name "Bill Gates", and you can create another person with different name right? I just think that the member functions or methods are what the object can do, like walking, sleeping, etc. And the member variables are the object's characteristics or properties.
If you initiated two persons here let's say bill and paul., it wouldn't affect paul if bill smoke weed but it affects bill's health.
Hope that helps