Basically, we are going to analyse the setup of this code:
Code:
#include <iostream>
#include <string>
using namespace std;
//--
class CSomeClass
{
public:
void Print(const string text)
{
cout<<text<<endl<<endl;
}
};
//--
int main(int argc, char* argv[])
{
CSomeClass obj_1;
CSomeClass obj_2;
obj_1.Print ("Object 1 made me print this");
obj_2.Print ("Object 2 made me print this");
return 0;
}
Ever wondered how CSomeClass::Print() knew which text to print correctly?
One could say: 'Well, you've typed it. It's right there on paper.'
But that wasn't the question. How did void CsomeClass::Print() knew? Knowing the answer to my question is the whole point of this tutorial. Remember, there is only one unique void CsomeClass::Print(const string text). Just look at the class above. Below is an image to illustrate the problem:
Before an answer is given, a small recap on objects will be given first.