错误代码示意:
ViBe.h
class ViBe
    {
    
   
int c_xoff[9] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 };
}
运行c++代码提示:
    error C2536: “ViBe::ViBe::c_xoff”: 无法指定数组的显式初始值设定项
    
   
尝试在.h 中定义变量,构造函数中进行初始化后提示以下错误:
error C2440: “=”: 无法从“initializer-list”转换为“int”
解决办法:
    类定义的里面非静态成员变量定义的时候不可以初始化的
    
   
   在类中定义数组变量,然后在构造函数中赋值;
   
   ViBe::ViBe()
   
   {
   
   
   
   int temp_arr[9] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 };
   
   
   
   memcpy(c_xoff, temp_arr, sizeof(temp_arr));
   
}
=================分割线================
    在查找解决办法的时候以下博客提供了比较好的解决思路,可以参考
    
   
http://www.cnblogs.com/tziyachi/archive/2012/02/26/2368655.html
    https://blog.csdn.net/qqaiustc/article/details/38742435
    
   
   https://blog.csdn.net/misayaaaaa/article/details/61195389
   
  
 
