obj.method(arg) memory

From: Edo (edwardoJE_at_aking.com)
Date: 06/06/04


Date: Sun, 06 Jun 2004 01:50:09 -0700

Hello
I am not sure if I understand that the difference between the 2 codes
below is basicly how each C/C++ handle memory. in the sence of when
in C++
obj_1.Print ("bla bla") //compiler pass the pointer of the memroy
location of the obj_1 to the method void Print(string text)
where as in C
you need the "*" in Print(char* text) inorder for the compiler to do the
same?

also where we are here, what’s this "int argc, char* argv[]" in the int
main function and sometimes I see int argc, char** argv[], in my
hrs/days/weeks of reading I did not come across an explanation yet.

thanks

#include <iostream>
#include <string>
using namespace std;

class CPlusPlusSomeClass
{
public:
        void Print(string text)
        {
                cout<<text<<endl<<endl;
        }

};

int main()
{
        CPlusPlusSomeClass obj_1;
        CPlusPlusSomeClass obj_2;

        obj_1.Print ("Object 1 made me print this");
        obj_2.Print ("Object 2 made me print this");

        return 0;
}

#include <iostream.h>
#include <string.h>

class CSomeClass
{
public:
        void Print(char* 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;
}