Johan wrote:
[color=blue]
> Where can I find coding example in C++ for homogeneous container.[/color]
std::deque<int>
There - they integers, so they are all the same: homo!
Nonono I'm not calling you "homo" - that's what "homo" means: same!
Oh, you meant a "heterogeno us container". That's: different!
If you need a hetero container of primitives - int, float, string - you need
a VARIANT type. Check out your nearest non-Standard library, such as Qt, or
boost.org, or COM. They provide types such as QVariant, Any, or _variant_t,
which hold many kinds of primitives, and handles to ORB objects.
Put them all in bed together like this:
std::deque<QVar iant>
Next, if you need to store many types derived from a base class, you need a
collection of pointers to it:
std::deque<Base *>
Now you can push the addresses of objects of classes derived from Base into
the collection.
That won't delete any heap objects when the deque disappears, so see www.boost.org for adapters such as shared_ptr<>, and for more code samples
than you thought possible.
[BTW there were several other wicked puns available here, so I deserve
credit for the superhuman effort of avoiding them;]
"Johan" <me@knoware.n l> wrote in message
news:10n27i3qtc bb4c4@corp.supe rnews.com...[color=blue]
> Hi,
>
> Where can I find coding example in C++ for homogeneous container.[/color]
All of the C++ standard library container types are
homogenous by definition.
Coding example:
#include <vector>
int main()
{
std::vector<int > container;
return 0;
}
Comment