On Sun, 08 Feb 2009 09:36:09 -0800, ArbolOne wrote:

> I am learning std::vector, like this:
>
> class MyClass{
>       private:
>          std::vector<MyContainer> record;
>       public:
>       MyClass();
> 
>       void setRecord(std::vector& obj);
                       ^^^^^^^^^^^  
//      std::vector is a template - must specify
//      template parameter. Also best to make the
//      parameter const, as it is (should) not be
//      changed by a "set" method.

        void setRecord(const std::vector<MyContainer>& obj) {record = obj;}

>       std::vector<MyClass>& getRecord(){ return record;}
                    ^^^^^^^
//      Template parameters must match - std::vector<typeA> and
//      std::vector<typeB> are different types. Also best to
//      make a "get" method const, as it doesn't (shouldn't)
//      change the invoking object.

        std::vector<MyContainer>& getRecord() const {return record;}

>    };

I'd suggest that in future you try to compile your code and look carefully 
at any compiler error messages (admittedly they can be quite obscure, 
particularly where templates are involved...).

I'd also recommend that you post queries about C++ language issues (ie. 
not g++-specific) to a C++ language newsgroup, such as comp.lang.c++.

Best,

-- 
Lionel B
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to