I have this snippet of the code:
void addLineRelative(LineNumber number, LineNumber relativeNumber) { list<shared_ptr<Line> >::iterator i; findLine(i, number); if(i == listOfLines.end()){ throw "LineDoesNotExist"; } line 15 if(dynamic_cast<shared_ptr<FamilyLine> >(*i)){ cout << "Family Line"; } else { throw "Not A Family Line"; } } I have class Line and derived from it FamilyLine and RegularLine, so I want find FamilyLine
my program fails on the line 15, I receive an error
cannot dynamic_cast target is not pointer or reference can somebody please help, thanks in advance
edited
I tried this one:
shared_ptr<FamilyLine> ptr(dynamic_cast<shared_ptr<FamilyLine> >(*i)); if(ptr){ //do stuff } the same error
edited
void addLineRelative(LineNumber number, LineNumber relativeNumber) { list<shared_ptr<Line> >::iterator i; findLine(i, number); if(i == listOfLines.end()){ throw "LineDoesNotExist"; } shared_ptr<FamilyLine> ptr(dynamic_pointer_cast<FamilyLine>(*i)); if (ptr){ cout << "Family Line"; } else { throw "Not A Family Line"; } } receive this error
Multiple markers at this line - `dynamic_pointer_cast' was not declared in this scope - unused variable 'dynamic_pointer_cast' - expected primary-expression before '>' token