variable `xxx' has initializer but incomplete type
生活随笔
收集整理的這篇文章主要介紹了
variable `xxx' has initializer but incomplete type
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
錯誤:variable `xxx' has initializer but incomplete type?
原因:xxx對應的類型沒有找到,只把xxx聲明了但是沒給出定義。編譯器無從確認你調用的構造函數是什么,在哪兒
一般是沒有包含定義xxx的頭文件。
比如:
1 MyClass theObj; 2 const QMetaObject* metaObj = theObj.metaObject(); 3 //1.遍歷類的屬性 4 int propertyCnt = metaObj->propertyCount(); 5 for ( int i = 0; i < propertyCnt; ++ i ) 6 { 7 QMetaProperty oneProperty = metaObj->property(i); 8 std::cout << " name: " << oneProperty.name(); 9 std::cout << " type: " << QVariant::typeToName( oneProperty.type()) << "\n"; 10 }不包含頭文件的話會報一下錯誤:
使用#include <QMetaProperty>即可。
轉載于:https://www.cnblogs.com/liushui-sky/p/5729085.html
總結
以上是生活随笔為你收集整理的variable `xxx' has initializer but incomplete type的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gulp与grunt对比
- 下一篇: WebView跳转到底部