How can I initialize the default value of a CArray<CClass*> function parameter with an empty CArray?

我是研究僧i 提交于 2019-12-02 07:36:13

With this declaration

void Function(CArray<CClass*> parameter /*...*/);

You can't. Calling this function will invoke the private copy constructor of CObject as you have noticed.

What you could do, is to add a object of static CArray<CClass*> in your class and initialize the function with a reference to it. This way it will be empty (as long as you do not populate it...) and you can perform a .IsEmpty() check on it.

private:
    static CArray<CClass*> myObj;
//...
void Function(CArray<CClass*> &parameter = myObj);

Or initialize it to 0. This way you simply check it by if (parameter) or if (NULL == parameter).

void Function(CArray<CClass*> *parameter = NULL);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!