数组作为参数的c语言程序,如何在构造函数中传递数组作为参数? C

我正在尝试为类调用创建一个构造函数,其中4个数组作为参数传递.我尝试过使用*,&和数组本身;但是,当我将参数中的值分配给类中的变量时,我收到此错误:

call.cpp: In constructor ‘call::call(int*, int*, char*, char*)’:

call.cpp:4:15: error: incompatible types in assignment of ‘int*’ to ‘int [8]’

call.cpp:5:16: error: incompatible types in assignment of ‘int*’ to ‘int [8]’

call.cpp:6:16: error: incompatible types in assignment of ‘char*’ to ‘char [14]’

call.cpp:7:16: error: incompatible types in assignment of ‘char*’ to ‘char [14]’

感谢您帮助我找到错误并帮助我纠正错误.

这是我的代码:

.h文件

#ifndef call_h

#define call_h

class call{

private:

int FROMNU[8];

int DESTNUM[8];

char INITIME[14];

char ENDTIME[14];

public:

call(int *,int *,char *,char *);

};

#endif

.cpp文件

call:: call(int FROMNU[8],int DESTNUM[8],char INITIME[14],char ENDTIME[14]){

this->FROMNU=FROMNU;

this->DESTNUM=DESTNUM;

this->INITIME=INITIME;

this->ENDTIME=ENDTIME;

}

    原文作者:叶寒露
    原文地址: https://blog.csdn.net/weixin_28848739/article/details/117069076
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞