Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <qapplication.h>
#include <qvaluevector.h>
class Test
{
public:
void test()
{
qDebug("Test test()");
}
void test2()
{
qDebug("Test test2()");
}
};
int main ( int argc, char *argv[] )
{
QValueVector<Test> vv;
QValueVector<Test*> pp;
vv.push_back(Test());
vv.push_back(Test());
pp.push_back(new Test());
pp.push_back(new Test());
vv[0].test();
vv[1].test2();
pp[0]->test();
pp[1]->test2();
int i;
for (i = 0; i < pp.count(); ++i)
delete pp[i];
return 0;
}
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#include <qapplication.h>
#include <qvaluevector.h>
class Test
{
public:
void test()
{
qDebug("Test test()");
}
void test2()
{
qDebug("Test test2()");
}
void test3() const
{
qDebug("Test test3()");
}
private:
int m_obj;
};
int main ( int argc, char *argv[] )
{
QValueVector<Test> vv;
QValueVector<Test*> pp;
vv.push_back(Test());
vv.push_back(Test());
pp.push_back(new Test());
pp.push_back(new Test());
vv[0].test();
vv[1].test2();
pp[0]->test();
pp[1]->test2();
QValueVector<const Test*> ppconst;
ppconst.push_back(new Test());
ppconst.push_back(new Test());
// ppconst[0]->test(); // will not compile
ppconst[1]->test3();
int i;
for (i = 0; i < pp.count(); ++i)
delete pp[i];
for (i = 0; i < ppconst.count(); ++i)
delete ppconst[i];
return 0;
}
|
This post has been edited 1 times, last edit by "Messenger" (Apr 16th 2008, 6:22pm)