Thread: C++0x ???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Quote Originally Posted by Akkernight View Post
    Hmm... It is possible to copy the contents from a vector to list, right? Or is there some cool feature like conversion?
    Anyways, as a personal task, Imma make a function that... Does kinda what I talked about :P Even tho it'll definetly be a waste of everything, I find such tasks fun ^^

    EDIT: Meh, was a fail, but fun anyways :P I dunno how to make one function that accepts both vectors and lists, and I dunno how to allow it to accept all kinds of types, standard or custom :P like int, double or string, but I still made one that accept vector<string> ! :P
    Fill in the blanks to complete your vectorlist class:
    Code:
    #include <vector>
    #include <list>
    
    template <typename T>
    class vectorlist{
     public:
      vectorlist(){};
      
      void push_back( const T& d );
    
      // Fill in the blanks w/ other member funcs
      
     private:
      std::list<T> mlist;
      std::vector<T> mvec;
    };
    template <typename T> void
    vectorlist<T>::push_back( const T& d ){
     
     mlist.push_back( d );
     mvec.push_back( d );
    }
    
    // Fill in the blanks with other member funcs
    
    int main(){
     
     vectorlist<int> vl;
     return 0;
    }
    EDIT: My goal is after filling in several more "blanks" the repetitive nature of this project begins to reveal its own futility...
    Last edited by dudeomanodude; 12-05-2008 at 02:38 PM.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

Popular pages Recent additions subscribe to a feed