Thread: Using STL with Microsoft Visual Studio C++ 6?

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    9

    Using STL with Microsoft Visual Studio C++ 6?

    I've tried using SGI's STL with MSVC++ 6, but it failed miserably.

    Basically, I'm making a Win32 console app that requires the Vector, String, and Set classes. Are these classes built-in to MSVC++ 6, or available for download from any place other than SGI?

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    9
    Reason I'm asking:

    Code:
    #include <iostream.h>
    #include <fstream.h>
    #include <io.h>
    #include <vector>
    
    void quickSort();
    
    int main(int argc, char* argv[]) {
    	if (argc == 1) {
    		cout<<"ERROR:\tNo input file specified.\n";
    	}
    
    	
    	if (access(argv[1], 00)) {
    		cout<<"ERROR:\tThe input file does not exist.\n";
    	}
    	ifstream inputFile(argv[1]);
    	// Do all the input stuff
    
    	vector<int> vec;  
    	for (int i(0); i < 4; i++) {
    		vec.push_back(i);
    	}
    	for (int i(0); i < vec.size(); i++) {
    		cout<<vec[i];
    	}
    	inputFile.close();
    
    	// Process the input
    	// Sort the input
    
    	ofstream outputFile("output.txt");
    	// Do all the output stuff
    	outputFile.close();
    
    	return(0);
    }
    
    void quickSort() {
    	cout<<"Sort.\n";
    }
    produces:
    Code:
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(22) : error C2065: 'vector' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(22) : error C2062: type 'int' unexpected
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(24) : error C2065: 'vec' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(24) : error C2228: left of '.push_back' must have class/struct/union type
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(26) : error C2374: 'i' : redefinition; multiple initialization
            C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(23) : see declaration of 'i'
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(26) : error C2228: left of '.size' must have class/struct/union type
    C:\Program Files\Microsoft Visual Studio\MyProjects\td2sql\td2sql.cpp(27) : error C2109: subscript requires array or pointer type
    Error executing cl.exe.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Try 'std::vector' instead of just 'vector'
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    9
    /me slaps forehead

    d0h. So used to C++ in an older version of the g++ compiler ... no namespaces necessary there

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Apps that act "differently" in XP SP2
    By Stan100 in forum Tech Board
    Replies: 6
    Last Post: 08-16-2004, 10:38 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 04:07 PM