December 3rd, 2003, 05:05 PM
STL and pointer/reference question
Im rather new to C++ (I´m changing from Java to C++), so please bear with me.
I have a question about STL and returning a vector array
from a static method.
How do I do it correctly, so that the function contructs
a vector that can be returned to the caller. I know if I
create a local object from a class and return it`s reference, it will point to null (if I´m rigth) after the
function call. So the object should be created with the new
operator. But how do I do it with template call??
I just get errors when I try to compile.
It should go something like this(please, do correct my syntax, pointers and references are used very wrong, I think):
static &vector<MyClass> loadFromFile()
vector<MyClass> *data = NULL;
// load from file and populate the vector
ps. could somebody tell me where to fing a decent
standard C++ API (yes, I`m migrating from Java to C++). All I have found are rather hard to use / read or incomplete.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!