QVector<T> * dont want work with operator
Hello everyone. Please, help me to understand, why when I'm have, for example
@QVector<double> *p = new QVector<double>()@
This is the proper way to use QVector as an array.
vec = 0.0; // uses the overloaded operator
// vec is a container
You can use:
double *p = new double;
p= 0.0; // you use the access operator with an offset
// p is a pointer to double. Sou you can assign a double as
What you did:
QVector<double> *p; // this is a pointer to an object of QVector<double>
p = new QVector<double>(); // you allocate the memory of the object.
// p = // you access an object of QVector with offset 0, but
QVector &vec = *p; // this should work
vec = p; // you assign the whole vector to vec
vec = 0.0; // this will work ; you assign 0.0 to the first element of
(*p) = 0.0; // this should also work
The answer to your question is that the compiler recognizes your construct as an offset of a pointer, but the indication of one element in the vector is still missing.
but I did not check it out.
Oooh, now I'm understand. Thank you very much.
[quote]Are you sure that this is working?[/quote]
Of couse I'm mean ->, just written by hand and do mistake.
[quote author="UndeadDragon" date="1383328028"]Oooh, now I'm understand. Thank you very much.
You are welcome!
[quote author="UndeadDragon" date="1383328028"]
Of couse I'm mean ->, just written by hand and do mistake.[/quote]
I thought so ;-)