![]() |
|
#1
|
|||
|
|||
C++ VectorsHi,
Can anyone help me, I am in the middle of a project for college and I'm badly stuck. I'm trying to use Vectors in and also File I/O. The problem occurs when I put in the import statements to alllow me to use vectors. When I put them in, the compiler no longer recognises my file stream object and comes up with the error: C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(23) : error C2872: 'ofstream' : ambiguous symbol C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.cpp(52) : error C2872: 'ifstream' : ambiguous symbol Error executing cl.exe. Test.exe - 2 error(s), 0 warning(s) Ive tested the code for the files separately and the vector part separately and there's nothing wrong, both work perfectly, it seems to be just when I put em together. I'm ready to tear my hair out at this stage. |
|
#2
|
||||
|
||||
|
It might help if you post the code
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business. |
|
#3
|
|||
|
|||
|
I've seen that ifstream & ofstream are defined in both string and fstream.h. I guess you're using namespace std - but it doesn't seem to work sometimes. You've to be careful about which ifstream you're referring to. So for using ifstream/ofstream, I think you should try using the following syntax:
CPP / C++ / C Code:
Hope this works. Some compilers handle this better than others sadly. GF |
|
#4
|
|||
|
|||
|
The problem with Microsoft Visual C is that you have to include the files without the .h, it is
#include <iostream> #include <fstream> Hapened the same with me. Hope this help |
|
#5
|
|||
|
|||
|
If you are using vectors and reading from a file, please i would like to take a look at your code, it would be of lot of help to me.
mail:jmenendezr@hotmail.com Thx |
|
#6
|
||||
|
||||
some vetor basicsVectors are something like arrays accept you don't have to specify a size and elements can be automatically placed without specifying the element location. Vectors are used much like a push in a pop and push data structure of an array accept there is no popping off the back of the line. You do this by using the push_back function.
example: CPP / C++ / C Code:
some vector functions: size() empty() max_size() begin() end() But they are right, I can't be much more help without seeing your code. |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The