1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C++ question

  1. Jul 7, 2008 #1
    If I have a function that takes a std::vector< T1 > and I pass it a std::vector< T2 >, where T2 is publicly derived from T1, that should work, why does my compiler complain?
     
  2. jcsd
  3. Jul 7, 2008 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    What makes you think that should work? A vector of references or pointers might work; note well that I am not saying it will. A vector of actual instances is a different beast. I would think that this should not work.
     
  4. Jul 7, 2008 #3

    rcgldr

    User Avatar
    Homework Helper

    You have to pass a pointer to the vector, and make sure the vector elements are the same.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: C++ question
  1. C++ question (Replies: 2)

Loading...