![](/img/trans.png)
[英]C++ type cast operator code that won't compile in visual studio 2012, but worked fine in visual studio 2005
[英]Typo in scope operator leads to unexpected compile and recursion in Visual Studio 2012
我有這樣的類結構:
class A{
public:
void foo();
};
class B: public A{
public:
void foo();
};
B :: foo()的實現如下:
void B::foo(){
A:foo();
}
很明顯,我在輸入'::'時犯了一個錯誤,但是編譯器沒有抱怨。 當我運行該程序時,它就像我輸入的那樣運行:
void B::foo(){
foo();
}
任何人都可以在C ++標准中解釋這一點嗎? 它是真正有效的代碼,還是編譯器中可能存在的錯誤(MS Visual Studio 2012)?
A:
標簽,用於goto
statememt。
void B::foo(){
goto A;
std::cout << "this will be skipped";
A:foo();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.