0
我有代码:C++内存泄漏或不
class foo
{
public:
bar(const QString& s){}
.....
};
int main()
{
.....
foo f;
for(int i = 0; i < 100; i++)
f.bar(QString("%1").arg(i));
....
return 0;
}
我有字符串内存泄漏 “F(QString的(” 一些文本串 “));”或不?
又如
class foo
{
QUdpSocket socket;
public:
foo();
void send_msq();
};
foo::foo(){
socket.bind(QHostAddress("192.168.20.1"),50501);
}
void send_msq()
{
socket.writeDatagram(...);
}
我有 “(QHostAddress(socket.bind” 192.168.20.1上串中的任何问题 “),50501);” ?
你的代码不能编译。我会先做。 – Sven 2012-02-09 05:44:45
可能不是。 'QString'是为了追踪自己的记忆,而你只是传递一份副本。我假设'foo'有'xxx operator()(QString const&)'成员。 – 2012-02-09 05:45:19
你的意思是f.bar(QString(“some string text?”)); ? – grieve 2012-02-09 05:46:19