I have a class containing a pointer
template<Foo> class Class{
Foo * ptr;
public:
//constructors, assignment
Foo* view(){return ptr;}
}
and function taking Foo*
as an argument
double fn(Foo*){ /*Implementation*/ }
Does the implementation
Class C;
fn(C.view());
cause the class member ptr
to bee copied?
Yes, the pointer is passed by value, ie it's copied. Maybe twice, depending on optimizations. What it points to is not copied.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.