| Author |
Message |
Wong *nix forums beginner
Joined: 25 Feb 2005
Posts: 6
|
Posted: Mon Feb 07, 2005 1:10 pm Post subject:
Please give me a pointer
|
|
|
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::operator=( const a_class & an_argument )
{
/* Bla Bla Bla */
return *this;
}
So what is this in C++ ?
Thanks in advance. |
|
| Back to top |
|
 |
Karl Heinz Buchegger *nix forums Guru
Joined: 21 Feb 2005
Posts: 651
|
Posted: Mon Feb 07, 2005 1:14 pm Post subject:
Re: Please give me a pointer
|
|
|
Wong wrote:
| Quote: |
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::operator=( 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.
--
Karl Heinz Buchegger
kbuchegg@gascad.at |
|
| Back to top |
|
 |
Gernot Frisch *nix forums Guru Wannabe
Joined: 23 Feb 2005
Posts: 272
|
Posted: Mon Feb 07, 2005 1:17 pm Post subject:
Re: Please give me a pointer
|
|
|
"Wong" <tatto0_2000@yahoo.com> schrieb im Newsbeitrag
news:509bfe22.0502070610.3fb273de@posting.google.com...
| Quote: | 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::operator=( 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 |
|
| Back to top |
|
 |
kevin.hall@motioneng.com *nix forums beginner
Joined: 04 Feb 2005
Posts: 18
|
Posted: Mon Feb 07, 2005 8:10 pm Post subject:
Re: Please give me a pointer
|
|
|
"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::operator=(const
a_class&)". |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|