c++怎么重载‘=’然后输出字符串呢
1>e:\c++\eightteendays\eightteendays\test.cpp(29):errorC2440:“=”:无法从“int*”转换为“int[3]”...
1>e:\c++\eightteendays\eightteendays\test.cpp(29) : error C2440: “=”: 无法从“int *”转换为“int [3]”
怎么让disp()输出这个数组呢
#include<iostream>
using namespace std;
class test
{
public:
void intPut(int b[])
{
for (int i=0;i<3;i++)
{
A[i]=b[i];
}
}
void operator=(test c)
{
for(int i=0;i<3;i++)
this->A = c.A[i];
}
void display(){
cout<< this->A;
}
private:
int A[3];
};
int main()
{
test c;
int a[3]={1,2,3};
c.intPut(a);
c.display();
return 0;
} 展开
怎么让disp()输出这个数组呢
#include<iostream>
using namespace std;
class test
{
public:
void intPut(int b[])
{
for (int i=0;i<3;i++)
{
A[i]=b[i];
}
}
void operator=(test c)
{
for(int i=0;i<3;i++)
this->A = c.A[i];
}
void display(){
cout<< this->A;
}
private:
int A[3];
};
int main()
{
test c;
int a[3]={1,2,3};
c.intPut(a);
c.display();
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询