当前位置: 技术问答>linux和unix
高分请问完全使用QT做的程序在vc上进行编译联结的时候怎么会出现这样的问题
来源: 互联网 发布时间:2015-10-14
本文导语: 下面是出现的错误 其中的C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h是qt安装的目录中的一个文件 其中的错误就是说在QChar的定义中有这样的一个函数 friend inline bool operator!=( QChar c1, QChar c2 ); 其中的函数定义是这样的 in...
下面是出现的错误
其中的C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h是qt安装的目录中的一个文件
其中的错误就是说在QChar的定义中有这样的一个函数
friend inline bool operator!=( QChar c1, QChar c2 );
其中的函数定义是这样的
inline bool operator!=( QChar c1, QChar c2 )
{
return c1.ucs != c2.ucs;//错误就出现这里,说C2不能访问QChar的private变量其中的ucs是
//在QChar中定义的private: ushort ucs;
}
但是这里是QChar中声明的一个friend函数,语法上应该是可以的
在说这是QT库中实现的函数,这里怎么会出现错误呢?
我还以为是我的VC有问题,就将系统格了从新装,可后来还是不能解决问题,请问这是怎么回事
同样的程序我以前是可以调试通过的阿
请QT高手帮忙阿
谢谢了,问题解决了马上散分
谢谢了
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(300) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(305) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(310) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(310) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(315) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(315) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(320) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(325) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(330) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(335) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(340) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(340) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqpoint.h(74) : fatal error C1903: unable to recover from previous error(s); stopping compilation
其中的C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h是qt安装的目录中的一个文件
其中的错误就是说在QChar的定义中有这样的一个函数
friend inline bool operator!=( QChar c1, QChar c2 );
其中的函数定义是这样的
inline bool operator!=( QChar c1, QChar c2 )
{
return c1.ucs != c2.ucs;//错误就出现这里,说C2不能访问QChar的private变量其中的ucs是
//在QChar中定义的private: ushort ucs;
}
但是这里是QChar中声明的一个friend函数,语法上应该是可以的
在说这是QT库中实现的函数,这里怎么会出现错误呢?
我还以为是我的VC有问题,就将系统格了从新装,可后来还是不能解决问题,请问这是怎么回事
同样的程序我以前是可以调试通过的阿
请QT高手帮忙阿
谢谢了,问题解决了马上散分
谢谢了
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(300) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(305) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(310) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(310) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(315) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(315) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(320) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(325) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(330) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(335) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(340) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(340) : error C2248: 'ucs' : cannot access private member declared in class 'QChar'
C:QT3.2.1NONCOMMERCIALINCLUDEqstring.h(236) : see declaration of 'ucs'
C:QT3.2.1NONCOMMERCIALINCLUDEqpoint.h(74) : fatal error C1903: unable to recover from previous error(s); stopping compilation
|
VC 的SP6装没有?
检查自己代码里#include头文件的顺序
我在VC6下用以下代码不会报错,没办法模拟
class X
{
friend inline bool operator!=( X c1, X c2 );
private:
int m_privMemb;
};
inline bool operator!=( X c1, X c2 )
{
return c1.m_privMemb != c2.m_privMemb;
}
X x, x2;
void main()
{
if(x != x2)
printf("x != x2n");
else
printf("x == x2n");
}
检查自己代码里#include头文件的顺序
我在VC6下用以下代码不会报错,没办法模拟
class X
{
friend inline bool operator!=( X c1, X c2 );
private:
int m_privMemb;
};
inline bool operator!=( X c1, X c2 )
{
return c1.m_privMemb != c2.m_privMemb;
}
X x, x2;
void main()
{
if(x != x2)
printf("x != x2n");
else
printf("x == x2n");
}
|
回错了,友元函数可以访问类的私有成员,我以前遇到过这种情况,但怎么解决的忘了,对不起!不好意思.
|
这你是定义的重载函数还是QT的库函数?我想这样写才是对的:
先中你的Qchar类中定义一个成员函数:
inline bool compare( QChar c1, QChar c2 )
{
return c1.ucs != c2.ucs;
}
然后定义友元函数:
inline bool operator!=( QChar c1, QChar c2 )
{
return compare( QChar c1, QChar c2 )
}
先中你的Qchar类中定义一个成员函数:
inline bool compare( QChar c1, QChar c2 )
{
return c1.ucs != c2.ucs;
}
然后定义友元函数:
inline bool operator!=( QChar c1, QChar c2 )
{
return compare( QChar c1, QChar c2 )
}
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。