problem mit auto_ptr
-
hi!
// gebaeck.h class Gebaeck { .... private: std::auto_ptr<vector<SEMMEL>> v; // fehler: error C2947: expecting '>' to terminate template-argument-list, found '>>' }; //gebaeck.cpp Gebaeck::Gebaeck() { v = new vector(); }
komme aber einfach nicht drauf.
danke im voraus
-
std::auto_ptr<vector<SEMMEL> > v;
so ist es richtig
-
danke, jetzt kommt aber im Ktor bei v =new vector():
error C2512: 'std::vector' : no appropriate default constructor available
error C2955: 'std::vector' : use of class template requires template argument list
error C2955: 'std::vector' : use of class template requires template argument list
-
v = new std::vector<SEMMEL>;
-
jetzt kommt das:error C2514: 'std::vector' : class has no constructors
error C2955: 'std::vector' : use of class template requires template argument list
error C2955: 'std::vector' : use of class template requires template argument list
error C2275: 'SEMMEL' : illegal use of this type as an expression
-
ups .. mein fehler.
jetzt nur noch 1 problem:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::vector<_Ty,_Ax> *' (or there is no acceptable conversion)
with
[
_Ty=SEMMEL,
_Ax=std::allocator<SEMMEL>
]
-
std::auto_ptr<vector<SEMMEL> > v(new vector<SEMMEL>);
Was is SEMMEL eigentlich ?
-
Benutze besser eine Initialisiererliste:
class Gebaeck { auto_ptr<vector<Semmel> > v; public: Gebaeck(); }; Gebaeck::Gebaeck() : v(new vector<Semmel>) { }
-
Hallo,
nur mal so aus Interesse, warum packst du einen vector in einen auto_ptr?
-
dammit es keine speicherlöcher gibt?
-
Er meinte, warum du ihn überhaupt dynamisch allokierst.
Ein einfaches
class Gebaeck { vector<Semmel> v; };
tut es doch auch.