i working on project , after multiple searches error in title pretty lost. if may please figuring out.
class managedarray { public: float *elements; int numberofelements; /* default constructor */ managedarray() :elements(null){}; managedarray() :numberofelements(0){}; <--where error /*accessor*/ int size() {return numberofelements; } float get(int index) {return elements[index]; }
according c++ standard (9.2 class members)
- ...a member shall not declared twice in member-specification, except nested class or member class template can declared , later defined, , except enumeration can introduced opaque-enum-declaration , later redeclared enum-specifier.
you declared , defined default constructor 2 times
managedarray() :elements(null){}; managedarray() :numberofelements(0){}; <--where error
you add parameter second constructor example
managedarray() :elements(null){}; managedarray( int n ) :numberofelements(n){};
or following way
explicit managedarray( int n ) :numberofelements(n){}; ^^^^^^^^
take account instead of type int
better use type size_t
data member numberofelements
@ least because number of elements can not negative.
also both constructors should initialize data members.
for example
managedarray() :elements(null), numberofelements( 0 ){};
Comments
Post a Comment