![]() |
|
#1
|
|||
|
|||
Creating 2d arrayI'm new to C++ and I want learn how to create a 2d array to store numbers and names. Let's say I have an art class of 5 students, I want to create an array to store their names and ages. Then I want to create a function to return only their names. I'm having a hard time figuring out where to start. Here's what I have so far. Am I down the right path?
CPP / C++ / C Code:
Last edited by JdS : 21-Mar-2004 at 08:15.
Reason: please use the [c]your c code[/c] syntax highlighter
|
|||
|
#2
|
|||
|
|||
|
Hi, i think it would be easier for you if u made a student class which only stores name and age, and then make an array of student objects, which are in the art classroom. and then you can maybe have a function which returns array[studentnum].age or array[studentnum].name. remember a function can only return 1 variable or an object,and it can't return arrays. a void function like the one you have can't return anything. so you can put in the ampersand & in front of your parameters that you are passing to it so that any changes you make to the function parameters are actually made to the parameters that were passed to your function when it was called. By the way, it would be a good idea to get a c++ book and then after each chapter do a few problems.
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Speed up C++ code about 3d array! | Truong Son | C++ Forum | 0 | 16-Mar-2004 22:52 |
| throwing an struct(with an array) through a function | knakworstje | C Programming Language | 5 | 15-Feb-2004 17:20 |
| c: array comparison | jack | C Programming Language | 7 | 26-Jan-2004 12:21 |
| Sorting a 2D array c++ | mike3340 | C++ Forum | 4 | 15-Dec-2003 14:35 |
| Extra null element in an array | samtediou | MySQL / PHP Forum | 2 | 11-Dec-2003 12:52 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The