I have a class that makes use of one of two different vectors I declared in the class declaration depending on a datatype that has to be specified to the constructor.
Here are the two declarations:
Most of the functions I use to perform operations on these vectors are common or overloaded. This allows the type to be specified at the creation of the object.Code:std::vector<int> intVector; std::vector<char> charVector;
One thing I can't figure out is how to return either int or char, depending on the type in use, without having the implementer of my class have to decide which function to use.
For example, if someone invokes the return function as follows:
I want to return an int value from my intVector if the type in use is int, and if the type in use is char I want to return a char value from my charVector.Code:myClass::retVal();