eigene Klasse
-
Hi!
Ich schreibe zur Zeit an einer Klasse. Dabei hab ich ein Problem, das wohl ganz einfach ist, aber ich komm nicht dahinter:
template <class T> class dynarray { ... T& operator[](int index) { if (index+1>groesse) grow(index+1); return array[index]; } ... }
und in der main-Funktion
int i; string text; dynarray<string> liste(); cout<<"Index: "; cin>>i; cout<<"Text: "; cin>>text; [b]1:[/b]liste[i]=text; [b]2:[/b] cout<<"Auf Index "<<i<<" steht"<<liste[i]<<endl;
Das Problem:
1: pointer to a function used in arithmetic
1: assignment of read-only location
1: cannot convert `std::string' to `dynarraystd::string ()()' in
2: pointer to a function used in arithmeticWenn ihr mir da helfen könntet, wär das toll.
-
Ich will nur nochmal nachfragen: Dir ist bewusst, das du mit
dynarray<string> liste();
eine Funktion namens liste deklarierst?
-
Wie kann ich dann ein Dynarray deklarieren?
-
ohne ()