The basic concept behind classes is that the program relies more to data than to actions! In other words, you can take two objects of the same class and provide them with data that'll make them react differently.
Consider a variable like int or float to be a class ( although it isn't ). Let's declare some integers:
Code:
int a;
int b(0);
int c = 123;
int d(b);
int e = d;
Each of the above are independant from each other, each holding it's own value and performing it's own operations.
A class is like a species, like us humans!
An instance of a class is like me, you, each one who reads this topic etc. We are all built the same way, but given different data that make us respond differently to the same actions!!! ( I know that's a rough example but it'll do )
That's how a class is defined:
Code:
class someClass
{
public: // Everything under this can be used by anyone
someClass(); // Default Constructor, optional
~someClass(); //Destructor, optional
/* Here public functions and variables are declared */
protected: // Everything under this can be used only by this class's members and descendants
/* Here protected functions and variables are declared */
private: // Everything under this can be used only by this class's members
/* Here private functions and variables are declared */
};
You cannot make use of any operation inside the braces of a class and out the braces of a member function!
Get started with the above AND understand them before you go on. OOP is very exciting once you get the hand of it!
PS: Why do you include <cmath> and <stdafx.h> ??