Thread: Vectors in my Header Files?

  1. #1
    Registered User
    Join Date
    Nov 2004

    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
    int something;
    vector<int> temp;

    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.


  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    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.

    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
    Registered User
    Join Date
    Nov 2004
    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, 03: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
    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