码迷,mamicode.com
首页 > 其他好文 > 详细

variable `xxx' has initializer but incomplete type

时间:2016-08-02 14:54:12      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

错误: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>即可。

variable `xxx' has initializer but incomplete type

标签:

原文地址:http://www.cnblogs.com/liushui-sky/p/5729085.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!