数组作为参数的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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值