Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    cpp
  » Keyword: this
      by
 Page 2 of 6 
< Previous     Next >

(Login to remove green text ads)
Intro to simple code
Introducing the sample code

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.




 
 Page 2 of 6 
< Previous     Next >

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting