如何将成员数组作为C++中的默认值传递给成员函数?

问题描述

为什么以下是不可能的? 编译器的问题在于非静态成员引用必须被相关的一个对象。 但该变量是在同一个对象。我尝试使用指针 this 但这也是不允许的。

//header file
class test{
    int member_array[3] = {1,2,3};
    void member_function(int array[]);
};


//source file
#include "test.h"

void test::member_function(int array[] = member_array){
    //do something with array
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)