What are they for??

I am reading a C++ book and have a question.

class A
{
A(){}
A(const A&);
A& operator=(const A&);

};

what are the bold lines??
And they don't have body, so I don't know what they are.

Please Explain it. Thanks. :)
I think it is called overloading. I'm not to sure what the first one is doing, but the second one is creating a new operator for the class A with the symbol =. This is done so that the members of the class can use that symbol in place of some more tedious operations.

This is actually interesting and I am going to read more about it. Here is a link
http://www.cplusplus.com/doc/tutorial/classes2/
Just to add on to what Smac said those are called the copy constructor and assignment operator respectively (The copy constructor is always around even if you don't define it but it doesn't handle dynamic memory allocation well).
Normally if you have one you are going to need the other seeing as they both handle assigning values to an object.

http://www.cplusplus.com/articles/y8hv0pDG/
@Phiru


If you are reading a book on C++ then why are you asking what is it? I think the book contains an explanation what is it. So you behave yourself very strange.
Or you should read another book on C++ for beginners.
Last edited on
The book I am reading doesn't explain what they are and how they work.
(Just says, "copy and assignment should be private")
now I understand them. Thanks all. !

Last edited on
Topic archived. No new replies allowed.