OK, this is a loaded question, so here I go.
Objective: Up-cast a base object into a derived one
Break-Down:
Each object is a function object, meaning an object containing a single member function with a single argument.
The hierarchy is as follows:
1)Function Object: Template Interface, contains a single virtual method called execute
template < typename TYPE, typename T > __interface iFunctionObject {
public:
virtual TYPE Execute ( T ) = 0;
};
2)Strategy Object: An Abstract Interface derived from Function Object, member function remains virtual as it is not defined. Its purpose is primarily cosmetic as it helps in defining a common set of terminology.
template < typename TYPE, typename T >
__interface iStrategy : public iFunctionObject < TYPE, T > {};
3)Context Specific Definition: From iStrategy one last derived class is defined. Member function remains virtual with the only real change being an alias for the data to referenced within the member function and a default implementation that simply returns zero.
template < typename TYPE, typename T >
class Operation : public iStrategy < TYPE, T > {
public:
virtual TYPE Execute ( T Stuff) { return 0; };
};
4)Implementation: From this point I derive from "Operation" and overload the virtual function in each child object in order to perform a collection of algorithms, each require a single argument and return a value as specified in the template parameters.
5)Control Object: The controlling object possesses a data member that is an Operation Pointer. This pointer is meant to be Up-Casted into a specified Operation derivative. I'll spare you the details, but it involves a collection of enumerated values and a switch.
PROBLEM:
When I attempt to Up-Cast like so:
NewOperation < TYPE, T > *Ref;
this->Op_ptr = dynamic_cast < Operation < TYPE, T > * > ( Ref );
This code compiles but crashes at run-time when invoking the "Execute" member function because it cannot locate it within the newly casted operation pointer. Can anyone help me with this?