I am trying to overload several operators for a class assignment and give them the & lt; & Lt; And ++ operators work together. Below I am a sample of the code I am settling. I know if you have any ideas.
Normal template decaring
template (square t) square vector {public: class VectIter {friend class vector; Private: Vector & lt; T & gt; * V; // Type T indicates a vector object of index index; // represents the subscript number of the // array of vector public: vector (vector & lt; t & gt; & amp; x); T operator ++ (); T operator ++ (int); T operator - (); T operator - (int); T operator * (); Dost Ostream & amp; Operator & lt; & Lt; (Ostream & ou, const, vectIter & rhs) {outside & lt; & Lt; (* Rhs) & lt; & Lt; Endl; Return; }}; Vector (int sz); ~ Vector (); T & amp; Operator [] (int i); Zero ascending_sort (); Private: T * array; // t indicates the first element of an array of integer shapes; Zero swap (T & amp; amp; T & amp; }; And here's where the main error occurs:
vector & lt; Mystring & gt; Y (3); Y [0] = "bar"; Y [1] = "Foo"; Y [2] = "All" ;; Vector & lt; Mystring & gt; :: Vector Eater (Y); Cout & lt; & Lt; "\ N \ n test postfix -"; For (Int i = 0; I Here is a sample of operators I am using:
T vector & lt; T & gt; :: VectIter :: Operator ++ () {if (index == (* V). Size) index = 0; Other index ++; Return (* V). Array [index]; } T vector & lt; T & gt; :: VectIter :: Operator ++ (int post) {post = index; If (index == (* v). Size) index = 0; Other index ++; Return (* V). Night [post]; } This code works with the input variable but when I change it to my custom class mestring, I get an error.
your iterator operator ++ instead of an Iterter T , so your Iterator's operator & lt; & Lt; The call is not being received Most likely the mestring in the operator is not declared / defined or mestring 's operator & lt; & Lt; takes a non-constant reference as the second parameter and can not accept temporary return from your operator ++ . Edit: Viewing your updates in OP (It works int ) for your mastigg class & lt; & Lt; needs to be applied.
Comments
Post a Comment