Home > Back-end >  Why do you call two copy constructor?
Why do you call two copy constructor?

Time:11-26


To line the constructor of the parameter is not value the constructor calls a point

CodePudding user response:

My understanding is that the line first to the embedded object initialization call with an auxiliary constructor, then the line of the constructor and participate in a constructor calls don't know right

CodePudding user response:

Four copy goes like this:
1, argument b copy to parameter p2
2, the argument a copy give parameter p1
3, parameter p1 copy line object for p1
4, parameter p2 copy to the line object p2

If you don't want to copy many times, can write const& Parameter
Such as: line (point const& P1, point const& P2)
So I can get a call to construct two copies

CodePudding user response:

Can also use a pointer,
The line (point * p1, p2) point *
But there is no reference pointer fast
  • Related