我不确定我是否缺少一些基本的东西。但我无法理解为什么编译器生成错误此代码:带const函数的编译器错误
class A
{
};
class B
{
public:
B();
A* get() const;
private:
A* m_p;
};
B::B()
{
m_p = new A;
}
A* B::get() const
{
//This is compiling fine
return m_p;
}
class C
{
public:
A* get() const;
private:
A m_a;
};
A* C::get() const
{
//Compiler generates an error for this. Why?
return &m_a;
}
编辑:编译器错误:错误C2440:“回归”:无法从“常量类A *”转换为“类A *'转换失去了限定符
你能提供的编译器错误A.实例太? – 2009-02-09 13:28:04