how i can do a array of various data types with classes???

Status
Not open for further replies.

MACS

Newbie level 3
Joined
Sep 28, 2004
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
34
i need to do a data array of various data types (int, double,char) using classes... If there are some skilled programmer please help me...
 

Re: how i can do a array of various data types with classes?

If you are using C++, there are 3 chooses:
1) you can write the class by using template.
2) you can use Standard Template Library
3) If you are using Visual C++, you can try MFC collection classes
 

Re: how i can do a array of various data types with classes?

It depends on what you want to do!
Do you want to put different types into one array or do you want to make/use a general container class?

When you want a general container class, you should look at the stl (standard template library)
vector, list, map, set, ...
https://www.sgi.com/tech/stl/Vector.html
https://www.sgi.com/tech/stl/List.html
More info: https://www.sgi.com/tech/stl/table_of_contents.html

For the "different types into one array", perhaps you could use inheritance and create and "array" of (pointers to) the base class?
Be carefull with memory leaks ;-) C++ doesn't have a garbage collector by default!

Antharax
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…