![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Is there a way to have an array contain a mixture of integers, floates, strings, characters? Just like a Python list.
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
Null pointer?
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
look up polymorphism, or polomorphic array i cant remember how to do it but thats what its called/
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 89
Rep Power: 4
![]() |
make a generic object that contains several data types. overload the constructor and accessors. then use malloc() with new to create an array of pointers to your objects.
this will waste a lot of space, though. as every object will have one of everything. |
|
|
|
|
|
#5 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() ![]() |
standard template library... check it out.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#7 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
Yup, there is... it's called a character array...
atof() converts char * to float. atoi() converts char * to int. and as for strings, that's what a char pointer is basically...
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|