Hi friends,

--Qt Questions

I'm currently starting Qt programming and i have some questions:

Qt Code:
  1. class Foo
  2. {
  3. ...
  4. static QList<Area*> *areas;
  5. QList<Camera*> cameras;
  6. ...
  7. }
To copy to clipboard, switch view to plain text mode 

{Considerations-> Camera and Area are normal classes, no Qt involved.}

1)I have these two objects, should i (in the destructor) call delete or delete [] for them?

2)Should i call delete for each Camera* and Area* object?

3)What would change in the first and in the second answer if the Foo class was derivated from QObject?

--Non-Qt questions

These are questions that always haunted me and never got answered:

1)What's the big catch in using pointers, i know some cases that pointers are good (like when we want to point something ) but when there's the option of choosing between pointer or non-pointer what parameters should I obey to choose one of them? Like:
Qt Code:
  1. class Foo
  2. {
  3. Foo(){};
  4. ~Foo(){};
  5.  
  6. void callMe() { cout<<"im alive"; };
  7. }
  8.  
  9. void main()
  10. {
  11. Foo *f = new Foo(); //what are the advantages/disadivantages of using a pointer here instead of Foo f();
  12. f->callMe();
  13. delete f;
  14. return;
  15. }
To copy to clipboard, switch view to plain text mode 

2)
Qt Code:
  1. class Foo
  2. {
  3. Foo(){};
  4. ~Foo(){};
  5. }
  6.  
  7. void main()
  8. {
  9. Foo f();
  10. Foo *p_f = &f;
  11. delete p_f; //does 'f' gets deleted here or can i continue using it?
  12.  
  13. createFoo(p_f);
  14. //is p_f still valid here? i mean, wasn't the object f destroyed after leaving createFoo function?
  15. return;
  16. }
  17.  
  18. void createFoo(Foo* p_f)
  19. {
  20. Foo f();
  21. p_f = &f;
  22. }
To copy to clipboard, switch view to plain text mode 

Thank you!