vector of strings error

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2008
Posts: 160
Reputation: cam875 is an unknown quantity at this point 
Solved Threads: 3
cam875 cam875 is online now Online
Junior Poster

vector of strings error

 
0
  #1
Dec 31st, 2008
When i compile this code i get an error which states

main.cpp|38|error: no match for call to ‘(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) (long int&)’|

I am going to assume that this is something to do with trying to put the string in a different kind of string, so how should I fix this error, thanks in advance.

  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. string LogicMolecule;
  10. string ExecutableCodeName;
  11. string LogicMoleculeFileName;
  12. vector<string> LogicMolecules;
  13. long index;
  14.  
  15. cout << "Execute: ";
  16. cin >> ExecutableCodeName;
  17.  
  18. ExecutableCodeName = ExecutableCodeName + ".code";
  19.  
  20. ifstream ExecutableCodeFile;
  21. ExecutableCodeFile.open(ExecutableCodeName.c_str());
  22.  
  23. if (!ExecutableCodeFile.is_open())
  24. {
  25. cout << "\n";
  26. cout << "error: can't open ";
  27. cout << ExecutableCodeName;
  28. }
  29.  
  30. while (ExecutableCodeFile >> LogicMolecule)
  31. {
  32. LogicMolecules.push_back(LogicMolecule);
  33. }
  34.  
  35. ExecutableCodeFile.close();
  36.  
  37. index = 0;
  38. LogicMoleculeFileName = LogicMolecules(index) + ".logic molecule";
  39. ifstream LogicMoleculeFile;
  40. LogicMoleculeFile.open(LogicMoleculeFileName.c_str());
  41.  
  42.  
  43. if (!LogicMoleculeFile.is_open())
  44. {
  45. cout << "\n";
  46. cout << "error: can't open ";
  47. cout << LogicMoleculeFileName;
  48. }
  49. }
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,758
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 283
Lerner Lerner is offline Offline
Posting Virtuoso

Re: vector of strings error

 
0
  #2
Dec 31st, 2008
LogicMolecules(index)

Use square brackets rather than () in the above.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 160
Reputation: cam875 is an unknown quantity at this point 
Solved Threads: 3
cam875 cam875 is online now Online
Junior Poster

Re: vector of strings error

 
0
  #3
Dec 31st, 2008
ok that worked, wow thanks i feel like a complete noob, its my dumb VB6 class practices catching up with me lol.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 320 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC