Sunday, July 12, 2009

Can someone explain to me what is copy constructor, operator overloading, pointer and reference in C++?

A copy constructor for a class is a constructor that has an object of the class as its only parameter. It makes a new object that is a duplicate of the original object.





Operator overloading is defining new meaning for existing operators. For example, string classes usually overload the arithmetic "+" operation to mean string concatenation.





A pointer is a variable that holds the address of another variable.





A reference is another name for an existing object. If you have an object A, and you create an object B, which is a reference to A, when you modify B, you are actually modifying A.





When you have a subroutine, and you pass it a variable as a parameter, what the subroutine gets is a copy of the original value. If you changed the parameter in the subroutine, it does nothing to the original variables value.


If, however, you pass a reference to the variable, then any changes you make to the parameter in the subroutine are made to the original value.

Can someone explain to me what is copy constructor, operator overloading, pointer and reference in C++?
http://cplus.about.com/od/beginnerctutor...





try this link


No comments:

Post a Comment