类“QSharedPointer”的构造函数被声明为“显式”; - 如何解决此错误
尝试使用时出现以下错误:
typedef QSharedPointer<Test> CTest
CTest* Module::function(params)
{
CTestNew* ptr = new CTestNew(params);
dosomething();
return ptr;
}
然后在代码中将 Test* 替换为 CTest。 我缺少什么?
error C2664: 'QSharedPointer<T>::QSharedPointer(const QSharedPointer<T> &)' : cannot convert parameter 1 from 'CTestNew*' to 'const QSharedPointer<T> &'
with
[
T=Test
]
Reason: cannot convert from 'CTestNew *' to 'const QSharedPointer<T>'
with
[
T=Test
]
Constructor for class 'QSharedPointer<T>' is declared 'explicit'
with
[
T=Test
]
I get the following error when trying to use:
typedef QSharedPointer<Test> CTest
CTest* Module::function(params)
{
CTestNew* ptr = new CTestNew(params);
dosomething();
return ptr;
}
Then replace Test* with CTest in the code.
What am I missing?
error C2664: 'QSharedPointer<T>::QSharedPointer(const QSharedPointer<T> &)' : cannot convert parameter 1 from 'CTestNew*' to 'const QSharedPointer<T> &'
with
[
T=Test
]
Reason: cannot convert from 'CTestNew *' to 'const QSharedPointer<T>'
with
[
T=Test
]
Constructor for class 'QSharedPointer<T>' is declared 'explicit'
with
[
T=Test
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编译器错误表明
CTestNew
与Test
不同编辑:响应评论说
CTestNew
是抽象的子类测试
应该是:
Compiler error's saying that
CTestNew
isn't the same asTest
EDIT: In response to comments saying
CTestNew
is a subclass of the abstractTest
should be: