Hello all Question about Vector

This is a discussion on Hello all Question about Vector within the C++ Programming forums, part of the General Programming Boards category; Does anyone use linux g++? If so i tried to declare a vector and it fails. Saying function is undeclared ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    2

    Hello all Question about Vector

    Does anyone use linux g++? If so i tried to declare a vector and it fails. Saying function is undeclared ususaly meaning the function is is either diffent from the ones i learned and the books i have read in the past or what, but here it is.
    Code:
    //// creates a empty Vector Container
    vector<int> Can;
    Now I just wanted to create a empty one just so i can define it later.

    But it keeps giving me function needs to be declared.
    In my windows compiler or Bloodshed i used to use both its #include <vector>

    and i did the same here to be included so Im clueless hopefully someone has used g++ before.

    Also i have done it this way
    Code:
    vector <int> Can
    You know spacing it away from the word vector
    Last edited by Evenius; 01-08-2004 at 07:37 PM.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    have you #include<vector>??
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    std::vector<int> Can;

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    311
    std::vector<int> Can;
    or
    using std::vector;
    vector<int> Can;
    or, if you absolutely must
    using namespace std;

    Bloodshead in windows uses g++, just like stock linux, though you might have a very old version.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    2
    yea it was a old verison and all. Thanks guys this board seems to be alot faster it always springs to action so far lol. Whoa thanks guys.

    I just downloaded the newest verison.
    gcc-3.3.2

    Thanks guys

    P.S i did std:: on my old compiler and thats what the problem was. So thanks ill just use

    using namespace std; so i wont have to repeat it.

    Thanks

  6. #6
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Originally posted by Evenius
    ill just use

    using namespace std; so i wont have to repeat it.
    Why not get in the habit of using std:: ? If you always use that, and you get used to the look of it, then you won't have to worry about it again. If you use the using namespace std; method, then later when you start having bigger projects you'll find reasons why that might not be a good idea. In the long run it might be easier to make std:: a habit now.

    Anyway, its no big deal, just something to consider.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copying Array to Vector Question
    By bengreenwood in forum C++ Programming
    Replies: 1
    Last Post: 06-01-2009, 04:00 PM
  2. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 01:34 PM
  3. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM
  4. Question about view vector, position, and matrix speed
    By Silvercord in forum Game Programming
    Replies: 1
    Last Post: 02-03-2003, 12:37 PM
  5. Operators for 3D Vector Mathematics
    By Anarchist in forum C++ Programming
    Replies: 10
    Last Post: 01-31-2003, 07:33 PM

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