它爲什麼編譯?爲什麼我可以用指針賦值struct?
struct UE{
UE(bool a = true) { };
// UE(){}; // if UE took no initial args and called below, gcc will complain.
};
class VA {
protected:
UE ue;
public:
VA();
};
VA::VA()
{
ue = new UE(true); // ???why???
// ue = new UE(); // will complain
}
我試着用gcc(GCC)4.6.2。 如何分配一個指針結構?
它編譯VS2010。 – herohuyongtao
@herohuyongtao問題是爲什麼。答案是隱式轉換。 – juanchopanza
@HenkHolterman'new'返回一個指針。 –