Insanely difficult vector weird error pizza

This is a discussion on Insanely difficult vector weird error pizza within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <vector> using std::cout; using std::vector; int main() { vector <int> _v1; vector <int> _v2; _v1.push_back(3); _v1.push_back(10); ...

  1. #1
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656

    Insanely difficult vector weird error pizza

    Code:
    #include <iostream>
    #include <vector>
    using std::cout;
    using std::vector;
    
    int main() {
    	vector <int> _v1;
    	vector <int> _v2;
    
    	_v1.push_back(3);
    	_v1.push_back(10);
    	_v1.push_back(33);
    
    	for(int x=0; x<_v1.size(); x++) {
    		cout<< _v1[x] << " ";
    	}
    
    	if(!_v1.empty()) {
    		_v1.clear();
    	}
    
    	_v2.push_back(10);
    	_v1.push_back(10);
    	if(_v1 == _v2) {
    		_v1.push_back(20);
    	}
    
    	_v1.switch(1, 2);		// <---- DARN ERORS!!  GGRRAAHH!!
    	for(int y=0; y<_v1.size(); y++) {
    		cout << _v1[y] << " ";
    	}
    	return 0;
    }
    I keep getting this error:
    Code:
    kleid@Shiva:~/Programming/Laboratory$ g++ vectors.cpp
    vectors.cpp: In function `int main()':
    vectors.cpp:28: error: parse error before `switch'

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Rename your function - switch is a reserved word in C++. Perhaps something like, "swap"?

  3. #3
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Mistype! It happens to me all of the time!

    http://www.cprogramming.com/tutorial/stl/vector.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 3D animation (difficult?)
    By maes in forum Game Programming
    Replies: 3
    Last Post: 09-08-2003, 11:44 PM

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