![]() |
|
#1
|
|||
|
|||
Problem compiling a program, my first vector.I'm having a problem compiling a program that uses a vector. This is just to learn upon, but my problem stems from my book that I am reading: C++ Programming Language 3rd Edition by Bjarne Stroustrup. Seems as though, he doesn't tell you what preprocessor files are needed for vector... so I went hunting online and I believe I found out that it was <vector>. Now my problem is that it seems as though my compiler does not understand what I'm trying to express with my vector. I'm just about positive that it is the correct syntax, though, it doesn't seem to recognize it still... here is the code, it's not big at all, and following it is my compiler errors.
CPP / C++ / C Code:
... and the gcc/g++ output... Code:
I'm I doing something incorrect? |
|
#2
|
|||
|
|||
Re: Problem compiling a program, my first vector.I think that you have missed the point with vectors... There are lots of errors in your code and I am not clear what you are really trying to achieve. Your best bet would be to start with something really simple:
Create a vector of int. Add the values 10, 20, 30, 40 to the vector (forget about random numbers etc. - make sure you get out what you put in in the order you expect) Print all the values out from the beginning to the end. Later on put a class into the vector. __________________
Michael Dual Opteron 280 (2 x dual core) with 2Gb RAM, 2x36GB system drives, 2T on 3Ware 9500Mi RAID controller. Running Fedora Core 4. Using Anjuta IDE. Developemnt in C++ with MySQL (via mysql++). |
|
#3
|
||||
|
||||
Re: Problem compiling a program, my first vector.there's no need to make a struct for an entry. Just use a typedef. That will make your life easier, and it will simplify debugging.
CPP / C++ / C Code:
|
Recent GIDBlog
Halfway done! by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Unwinding a recursive bool function? | earachefl | C++ Forum | 13 | 08-Jun-2006 08:20 |
| Combining Vectors and References | Frankg | C++ Forum | 7 | 14-Jan-2006 06:17 |
| Runtime Problem involving "printf" in C Program | supamakia | C Programming Language | 2 | 09-Oct-2005 10:09 |
| Problem with program | breggo | C++ Forum | 3 | 08-Jun-2005 13:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The