帮我看一下这个程序,总是错误提示cannot convert from 'int' to 'const class A'
#include <iostream>
using namespace std;
class A
{
public:
void set(int x)
{
i = x;
}
int get()
{
return i;
}
private:
int i;
};
class B
{
public:
B(int a, int b, int c):x(a), width(b), length(c)
{
cout<<"长方体的面积为:"<<width.get()*length.get()<<endl;
}
private:
int x;
A width;
A length;
};
int main()
{
B b(10, 20, 30);
return 0;
}
错误提示为cannot convert from 'int' to 'const class A',但是我并没有将A的对象设为常量呀。
using namespace std;
class A
{
public:
void set(int x)
{
i = x;
}
int get()
{
return i;
}
private:
int i;
};
class B
{
public:
B(int a, int b, int c):x(a), width(b), length(c)
{
cout<<"长方体的面积为:"<<width.get()*length.get()<<endl;
}
private:
int x;
A width;
A length;
};
int main()
{
B b(10, 20, 30);
return 0;
}
错误提示为cannot convert from 'int' to 'const class A',但是我并没有将A的对象设为常量呀。
...全文


