difference
-
difference between the copy constructor and assignment operator
-
difference between the copy constructor and assignment operator
is this supposed to be a question ? i mean, grammaticaly speaking, you missed the punctuation and the fundamentals of "how to well form a sentence"... ;P i think you wanted to say : "What is the difference between copy constructors and assignment operators for a know type ?". well, if yes, the answer is simple. the copy constructor can be called once in an object life (at the beginning), when the operator can be called anytime. technically, they do what you tell them to do, so the object can result in being in the same state after both operations, but all depends on what you coded there...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
is this supposed to be a question ? i mean, grammaticaly speaking, you missed the punctuation and the fundamentals of "how to well form a sentence"... ;P i think you wanted to say : "What is the difference between copy constructors and assignment operators for a know type ?". well, if yes, the answer is simple. the copy constructor can be called once in an object life (at the beginning), when the operator can be called anytime. technically, they do what you tell them to do, so the object can result in being in the same state after both operations, but all depends on what you coded there...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
MY QUESTION IS What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor class A A a; A b; a=b;
-
MY QUESTION IS What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor class A A a; A b; a=b;
sarojkumarjena wrote:
MY QUESTION IS
Dont use caps while expecting others to help.
sarojkumarjena wrote:
What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor
copy constructor is called when object is function argument , passed by value. when object is returning by value, and object is initializing using other object. i.e.
class A
A a;
A b=a;Prasad Notifier using ATL
-
MY QUESTION IS What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor class A A a; A b; a=b;
copy constructors are sometimes called implicitely when using templates containers, or things like this. if you don't provide one, you'll get a compiler error saying that no copy constructor were found for the type xxx... moreover, when passing objects by value to/from functions, the objects are duplicated, thus the copy constructor
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
difference between the copy constructor and assignment operator
Any constructor, including a copy constructor, builds the object from uninitialized memory. Once the object is "built" all the class's invariants have been established. An assignment operator sets the state of the object but the class invariants have already been established by a constructor.
Steve
-
MY QUESTION IS What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor class A A a; A b; a=b;
sarojkumarjena wrote:
What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor
The assignment operator destroys/replaces an existing object. The copy constructor creates an object as copy of another object.
-
sarojkumarjena wrote:
What the copy constructor is doing we can do the same thing through assignment operator.So what is the advantage of copy constructor
The assignment operator destroys/replaces an existing object. The copy constructor creates an object as copy of another object.
SilentSilent wrote:
The assignment operator destroys an existing object
false in the sense that it doesn't call the object's destructor, but true in the sense that it modifies the object integrity
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
difference between the copy constructor and assignment operator
You might what to implement the copy construtor or assignment operator to do a deep copy instead of shallow copy and also if you want to do any specific thing while doing the copy.
-Prakash