Wysota:

Thanks a lot here is a bit more info on some of your own questions.

In the first code a (the structure that contains the QVector of pointers) is set in yet another functions that goes soemthing like this:

Qt Code:
  1. StructA function2(){
  2. StructA a;
  3. //Code that fills the pointer vectors. This has as many uses of the reserved word new
  4. //as vectors are needed for this function to return.
  5. returnb a;
  6. }
To copy to clipboard, switch view to plain text mode 

As I said before, One and only one of the potentially many pointers (Although in my current problem there are only 3) is needed. This is decided in function() and that needed pointer is assigned to b as the code showed before. So is this wrong? Should I try to do it some other way?

The second code you wrote (the for cicle with the deletes) I have tried. however not exactly like that. See since I return one of the values in the b.pointer assignation, that specific value (when i == some_index) I don't delete, because I thought then b.pointer would be pointing at nothing. Is this wrong?
Also this code has gotten me some weird behaviour in the code of function2. By weird behaviour I mean that the program crashes. And when I use qDebug() to find where it crashes, I get that it does so before code lines that contain local (local to function2) variable declarations. There are four declarations and the crash seems to occur on two of them. It varies on which, each time I execute the program.

The private variable PClass *c is private to the class itself but the entire class has access to it.

When I aske if it was the right way to resolve "ths" I was referring to my use of the
Qt Code:
  1. delete c
  2. switch (some_variable){
  3. case 0:
  4. c = new ClassA();
  5. break;
  6. case 1:
  7. c = new ClassB();
  8. break;
  9. }
To copy to clipboard, switch view to plain text mode 

To properly use a new class every time the user changes what they want to do. And by right way to solve this, I mean that it doesn't cause some sort of memory leak.

To answer your last comment, The QVectors in classes A and B (those that are declared in their respective .h files as private global class variables) are all QVectors of doubles. However there are cases where I have QVector < QVector <qreal> >. So where and how should I dispose of this? In the distructor? and how? using qDeleteAll?

Thanks for any help.