OK, thanks, you are right, both of programs below works fine.
1.
#include <stdio.h>
#include <unistd.h>
#include <QVector>
#include <QDebug>
struct myStruc {
int *array;
myStruc() {
qDebug() << "myStruc";
array = new int[ 3000*2000 ];
}
myStruc(const myStruc& struc1) {
qDebug() << "copyStruc";
array = new int[3000*2000];
for(int i=0;i<3000*2000;++i)
array[i]=struc1.array[i];
}
~myStruc() {
qDebug() << "~myStruc";
delete [] array;
}
};
void foo(const myStruc &v)
{
printf("%d\n", v.array[1]);
}
int main(int , char* [])
{
printf("hello\n");
fflush(stdout);
sleep(1);
myStruc currentStruc;
foo(currentStruc);
QVector<myStruc> myVector;
myVector.push_back(currentStruc);
}
#include <stdio.h>
#include <unistd.h>
#include <QVector>
#include <QDebug>
struct myStruc {
int *array;
myStruc() {
qDebug() << "myStruc";
array = new int[ 3000*2000 ];
}
myStruc(const myStruc& struc1) {
qDebug() << "copyStruc";
array = new int[3000*2000];
for(int i=0;i<3000*2000;++i)
array[i]=struc1.array[i];
}
~myStruc() {
qDebug() << "~myStruc";
delete [] array;
}
};
void foo(const myStruc &v)
{
printf("%d\n", v.array[1]);
}
int main(int , char* [])
{
printf("hello\n");
fflush(stdout);
sleep(1);
myStruc currentStruc;
foo(currentStruc);
QVector<myStruc> myVector;
myVector.push_back(currentStruc);
}
To copy to clipboard, switch view to plain text mode
2.
int main(int,char* [])
{
QVector<int> array(3000*2000);
QVector<QVector<int> > myVector;
myVector.push_back(array);
}
int main(int,char* [])
{
QVector<int> array(3000*2000);
QVector<QVector<int> > myVector;
myVector.push_back(array);
}
To copy to clipboard, switch view to plain text mode
Bookmarks