Monday 15 April 2013

c++ - Inheritence doesn't seem to be working properly -



c++ - Inheritence doesn't seem to be working properly -

so i've got 3 files hoemwork assignment, question dosen't relate assignment, trying figure out why code i'm suppose utilize bassis assignment not compiling correctly.

so first there's abstract class (linkedlisttype) in file ( linkedlist.h ), can found here: >http://pastebin.com/stghvdds>

then class unorderedlinklist inherits (in file unorderedlinkedlist.h), can found here http://pastebin.com/yyv5vt7i

there no seperate .cpp files, in .h file those.

when compile main/test programme (just see errors i'll before begin assignment) lots of errors similar this:

unorderedlinkedlist.h: in fellow member function ‘bool unorderedlinkedlist::search(const type&) const’: unorderedlinkedlist.h:46: error: ‘first’ not declared in scope unorderedlinkedlist.h: in fellow member function ‘void unorderedlinkedlist::insertfirst(const type&)’: unorderedlinkedlist.h:66: error: ‘first’ not declared in scope*

they revolve around ('not declared in scope').

someone suggested using linkedlisttype:: access approach variables (which defined private in linkedlisttype), didn't help problem.

help, please, can hurry , parts of homework can't until know why isn't working. don't htink i"m trying homework me: homework write several methods given professor manipulate linked lists.

thanks!

your problem seek access name first independent name not found in scope: class templates not templated base of operations classes find names unless name made dependent name. non-dependent names resolved during phase look-up @ point base of operations class unknown (it specialized have exclusively different layout). dependent names looked during phase ii look-up.

thus, need create name first dependent name using, e.g.,

this->first linkedlisttype<t>::first

my personal preference utilize this-> nicely takes care of stating meant , doesn't need changed if location of fellow member changes.

c++ inheritance compiler-errors

No comments:

Post a Comment