Quote Originally Posted by aarelovich View Post
Qt Code:
  1. StructB function(){
  2. StructA a;
  3. StructB b;
  4. //Do stuff that initializes a and b
  5. //In this stuff, there is a line that goes like b.pointer = a.vector[some_index];
  6. return b;
  7. }
To copy to clipboard, switch view to plain text mode 
If you have such structure then returning b might cause a problem in itself unrelated to memory consuption. You are probably returning a pointer to a local object. Of course it depends on where "a" gets its values from...

How do I properly delete a? Or don't I have to?
You don't have to (and even shouldn't) delete "a" but you might have to delete its contents. (for(int i=0;i<a.size();i++) delete a[i]; or qDeleteAll(a)


In ClassC.h there is a private variable declared like:
PClass *c;
"private" to what scope? Some object or is it a global variable?

Is this the right way to resolve this?
I'm... not sure what it is supposed to do

Also Both Classes B and A have an extensive ammount of QVectors... Should I destroy (using QVector::clear() command) all the vectors in the Classe's Destructor?
Vectors clear themselves upon destruction but they only destruct objects they carry, so if you have a vector of pointers, only pointers will get 'destroyed', not the objects behind them. In that case you have to call qDeleteAll() on each vector (calling clear() is not enough because of the same reason).