I meets some problem with downcast in c++ programming language.
Thus, I needs your help.
My program has 5 classes. They are Employee (abstract class),Salary:public Employee,Hourly:public Employee,Commission:public Employee and BasePlusCom:public Commission.
In main() function,I used vector<Employee*>employees[4];
Then I assigned values to employees.
........
And I used structural syntax BasePlusCom* ComPtr=dynamic_cast<BasePlusCom*>(employees);
.....
And when compiles this program, compiler produces a warning that:
"dynamic_cast" used on polymorphic type 'class Employee' with G/R; unpredictable behavior may result.
And when I change dynamic_cast to reinterpret_cast then program run, but it not work properly.
How does casting in C++ differ?
gammavn 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.