Please give me a pointer

W

Wong

Hi,
I see some codings like this but I don't know C++. I would
appreciated if you can shed me a light. Just point me the term for me
to look for.

a_class & a_class::eek:perator=( const a_class & an_argument )
{
/* Bla Bla Bla */
return *this;
}


So what is this in C++ ?
Thanks in advance.
 
K

Karl Heinz Buchegger

Wong said:
Hi,
I see some codings like this but I don't know C++. I would
appreciated if you can shed me a light. Just point me the term for me
to look for.

a_class & a_class::eek:perator=( const a_class & an_argument )
{
/* Bla Bla Bla */
return *this;
}

So what is this in C++ ?
Thanks in advance.

It is a 'copy assignment operator' or often
simply called an 'assignment operator'.

You should find information on that in every
C++ book with those keywords.
 
G

Gernot Frisch

Wong said:
Hi,
I see some codings like this but I don't know C++. I would
appreciated if you can shed me a light. Just point me the term for
me
to look for.

a_class & a_class::eek:perator=( const a_class & an_argument )
{
/* Bla Bla Bla */
return *this;
}


So what is this in C++ ?

that's the function that get's called when you write:
a_class a, b;

a = b; // this line

where an_argument will be 'b', and *this will be 'a'.

HTH,
-Gernot
 
K

kevin.hall

"this" is a pointer to the class instance currently being acted on by
some class method.

In the example you wrote, "this" is a pointer to an instance of class
"a_class" being acted upon by the method "a_class::eek:perator=(const
a_class&)".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,650
Latest member
IanTylor5

Latest Threads

Top