STL help

This is a discussion on STL help within the C++ Programming forums, part of the General Programming Boards category; How come I can do like this: Code: #include <iostream> #include <vector> using namespace std; int main() { // Some ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    1,208

    STL help

    How come I can do like this:
    Code:
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main()
    {
    	
    	// Some constants
    	const int nRows = 5;
    	const int nCols = 11;
    
    	//Typedefs to save our fingers and improve readability
    	typedef vector<char> cArrayRow;
    	typedef vector<cArrayRow> cArray;
    
    	// Make an array:
    
    	cArray myArray(nRows,cArrayRow(nCols));
    }
    but not like this:
    Code:
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main()
    {
             const int nRows = 5;
    	const int nCols = 11;
    	vector<vector<char>> test(nRows, vector<char>(nCols));
    }
    I dont know much about STL but why can I do the former but not the later since they seem to be quite the same to me, only one uses typedefs and the other doesnt.
    Even this wont work:
    Code:
    vector<vector<char>> test;

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Add a space between the >.

    Code:
    vector<vector<char> > ...
    Kuphryn

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,208
    ah ok thnx guys!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Formatting Using STL
    By ChadJohnson in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2004, 04:52 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. STL or no STL
    By codec in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2004, 02:36 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21