Subscript Operator

From: Steve (steverigg_at_hotmail.com)
Date: 04/30/04


Date: Fri, 30 Apr 2004 16:36:21 +0100

Hi, I hope someone can help.

I have a class called cField, and another class called cFieldList.

cFieldList contains a std::vector of cFields called myvec

I've overloaded the subscript operator for cFieldList as so:

cField& operator[](int pos) { return myvec[pos]; }

however, when I compile the following code, I get an error:

cField f = MyFieldList[1]; // this an example, assume the objects exists
correctly

The compiler returns - Could not find a match for 'cField::operator
=(cFieldList)'

Anybody any ideas what I'm doing wrong?
Thanks in advance,
Steve.



Relevant Pages

  • Re: Subscript Operator
    ... subscript operator function is declared in this base class. ... I then have a class called cDCF which basically opens a file, ... > I have a class called cField, ... > however, when I compile the following code, I get an error: ...
    (comp.lang.cpp)
  • Re: Subscript Operator
    ... >I have a class called cField, ... >I've overloaded the subscript operator for cFieldList as so: ... >however, when I compile the following code, I get an error: ... On-Site Training in C/C++, Java, Perl and Unix ...
    (comp.lang.cpp)
  • Re: Subscript Operator
    ... > I have a class called cField, ... > I've overloaded the subscript operator for cFieldList as so: ... Post real compilable code, this should be easy to solve. ...
    (comp.lang.cpp)