Subj : Re: vectors To : borland.public.cpp.borlandcpp From : maeder Date : Wed Jul 28 2004 12:04 am "mike" writes: > class A > { > public: > vector& getPeople (); > > private: > vectorpeople_; > } > > the getPeople() just returns people_, however i wanted to know if this was > correct. if i return a reference to people_ it is much less overhead then > returning the entire vector. however when the A object is deleted (when i > create it i do A *a = new A ()), is the memory deallocated? Evaluating the delete expression delete a; will invoke the destructor of class A on *a. This is a compiler-generated destructor, since you don't provide it yourself, which is ok. This destructor will invoke the vector destructor on a->people_. > if so, it's probably just coincidence that my program works. That depends on what your program does. > i guess the only other alternative is to return a copy of the entire vector? I don't have enough information to answer this. .