Vectors in my Header Files?

This is a discussion on Vectors in my Header Files? within the C++ Programming forums, part of the General Programming Boards category; Hey guys, First post, getting reaquainted with c++. Did a little c++ back in college some 5-6 years ago, but ...

  1. #1
    Rv5
    Rv5 is offline
    Registered User
    Join Date
    Nov 2004
    Posts
    10

    Vectors in my Header Files?

    Hey guys,
    First post, getting reaquainted with c++. Did a little c++ back in college some 5-6 years ago, but spent most of my pro career doing asp and .net stuff. want to get back into c++.

    ive been trying to relearn the library and practice with it a little. can you not have vectors as members of a user class? for example, if i have a header file for a class im creating that looks something like below, i get an error with the vector:

    #include <vector>
    class myclass
    {
    private:
    int something;
    vector<int> temp;
    public:
    ...
    ...
    };

    perhaps its the java side of me that wants to do this. is it wrong? can i not get vector containers in my own objects? im sure there must be a way, but every example ive come across so far always has them in main, but that wont do me any good.

    thanks

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    a) Code tags. Make life easier.
    b) Knowing what the error is helps, but...
    c) vector is in the std namespace, so std::vector<int> ... should work out for you.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Rv5
    Rv5 is offline
    Registered User
    Join Date
    Nov 2004
    Posts
    10
    zach, thanks for the reply. forgot about code tags, will definitely use them in the future. silly of me not to give you the error, will do that in the future too. and yeah it was just the namespace deal. i dont think i ever would have thought of that. the error wasnt that descriptive. thanks again though, that helps a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  2. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. more header files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2001, 01:56 PM

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