What does “Class* &cls” mean in C++'s function definition?

前端 未结 4 2281
后悔当初
后悔当初 2020-12-15 01:45

I know Class *cls is a pointer, and Class &cls takes the address, but what is

void fucction1( Class *&cls)

If I have Class c

4条回答
  •  再見小時候
    2020-12-15 02:27

    For a type T, T* is a pointer to an object of type T, so Class* is a pointer to a Class object.

    For a type T, T& is a reference to an object of type T, so putting them together, Class*& is a reference to a pointer to a Class object.

提交回复
热议问题