C++ Generic List Assignment
- by S73417H
I've clearly been stuck in Java land for too long... Is it possible to do the C++ equivalent of the following Java code:
// Method
List<Bar> getBars() {
return new LinkedList<Bar>();
}
// Assignment statement.
List<Foo> stuff = getBars();
Where Foo is a sub-class of Bar.
So in C++....
std::list<Bar> & getBars()
{
std::list<Bar> bars;
return bars;
}
std::list<Foo> stuff = getBars();
Hope that makes sense....