I trying to understand polymorphism. Need some assistance in having the same character output to a window using visual studio 2012. So I would create a program of which if I entered in cat in the program when it is run, it will display something like that is an animal. If I enter in dog, it would display that is an animal. So it would run slightly different code but output the same result. Any assistance is appreciated. Thanks.
I can generate the generic programs input output, hello world etc. Although not sure how to make the code call to another say COM file to run in the code.
Would I be right in saying that you have been asked to write a program with an abstract base class and concrete classes for various different types of species? So, you are trying to ask how to implement such a program??
Right, so the idea is I have a base class, which will run a simple output to the window similar to a hello world simple code. The various species, but the species would run off of say a COM file. Correct. not sure how to create off of a COM input to trigger the same result in the output. Also not sure if I can do this within visual studio or if I need additional tools.
Here is what I have so far, but I need to tweak it so there is an input on the screen when I debut it. If the user inputs Comone there would only be one output "something funny, if the user input Comtwo the output would be "something funny", I started with if statements, but this each one did not incorporate separately like separate COM files. The way I have it they there are three messages of which pop "something funny". So I just do not know how to take the user input of either comone, cometwo or comethree and no matter what is input it would link to that part of header file and output "something funny" Thanks so much I appreciate the assistance.
const int cNumcom = 3;
int main()
{
Comfile* pFunny[cNumcom] = { new Comone, new Comtwo, new
Comthree };
for (int i = 0 ; i < cNumcom ; ++i)
{
std::cout << pFunny[i]->Sendsomthingfunny() << std::endl;
delete pFunny[i];
}
system ("pause");
return 0;
}