0

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?

4

1 回答 1

3

是的,指针是按值传递的,即它是复制的。可能两次,具体取决于优化。它指向的内容不会被复制。

于 2013-10-10T19:08:24.527 回答