Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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...
 

cevitamic

Newbie level 6
Joined
Dec 15, 2003
Messages
13
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
192
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
 

Antharax

Full Member level 4
Joined
Dec 31, 1999
Messages
208
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
2,865
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top