Help with vectors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ALi Shaikh
    New Member
    • Sep 2007
    • 18

    Help with vectors

    I need to declare something like this: apvector<int> roster(10);
    I need to change it so that the user can enter the length, so would this work( my compiler can't run vectors so I have no way of checking this)
    Code:
    cout<<"Enter the size of the vector: ";
    cin>>size;
    apvector<int> roster(size);
    Please help.
    Thanks in Advance.
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    How can your compiler not utilize vectors? The <vector> header is standardized across compilers. If you're working with a nonstandard class, as apvector would imply, just #include <vector> and replace apvector with vector. That said, assuming the input data is numeric, that should work, or at least it would for a standard vector.

    Comment

    • ALi Shaikh
      New Member
      • Sep 2007
      • 18

      #3
      Originally posted by Laharl
      How can your compiler not utilize vectors? The <vector> header is standardized across compilers. If you're working with a nonstandard class, as apvector would imply, just #include <vector> and replace apvector with vector. That said, assuming the input data is numeric, that should work, or at least it would for a standard vector.
      THANKS ALOT, I really didn't know that, now I can finally test my vector programs.
      One more thing can my compiler(Codewa rrior) do fstream,string, and matrix. Are these standard

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        CodeWarrior, as old as it is, should be able to handle the STL. A matrix class is nonstandard, though fstreams and strings are. For more information, look at this site, which contains documentation on the STL.

        Comment

        • ALi Shaikh
          New Member
          • Sep 2007
          • 18

          #5
          Originally posted by Laharl
          CodeWarrior, as old as it is, should be able to handle the STL. A matrix class is nonstandard, though fstreams and strings are. For more information, look at this site, which contains documentation on the STL.
          You just made life a whole lot easier man. Now ALL my programs work when I change apstring to string and apvector to vector.
          YOU ARE THE GREATEST PERSON EVER!!!!

          Comment

          Working...