Q:

data members as pointers

let's say I have the next class which include many data memebers:
Class A
{
public:
  .
  .
  .

private:

  string a1;
  string a2;
  vector<string> vec1;
  .
  .
  .
  .

}

and let's say I have a recursive function called foo() with many local variables of type A:
void foo()
{
  A a_1;
  A a_2;
  A a_3;
  .
  .
  .
  A a_n;
}

as you can see in the class definition, today, the data members of A are real objects and not pointers.
I know that all those data members are stored on the stack, the stack has a limited size (in my case 512MB) and I was wandering, will it be better to replace the data members with pointers which will point to data on the heap?
Thank you.

A:

I would say that the rule of thumb is "don't complicate your life by using pointers if you don't need to". 
In C++, there are references, that are (in my humble opinion) easier to use and understand. Regarding methods in a class, it's often necessary to pass objects by reference so that you avoid destroying objects you will need; but as far as variables go, I don't think it's very common that you need to use pointers. :)

