Ok, Damn oh well have to learn in order.
EDIT: YEY *Does the happy dance*
I got it to work
Code:
#include <fstream>
#include <iostream>
#include <string.h>
class First
{
public:
virtual void MyFunc() = 0;
~First() { };
};
class Second:
public First
{
public:
void MyFunc()
{
std::cout<<"Hello, world\n";
};
};
/* End of class */
class Third:
public First
{
public:
void MyFunc()
{
std::string Hello;
Hello="Hello world!\n";
std::cout<<Hello;
};
};
/* End of class */
class Fourth:
public First
{
public:
void MyFunc()
{
char hello[25];
strcpy(hello,"Hello world, my friend.\n");
printf(hello);
};
};
/* End of class */
int main()
{
std::ofstream a_file("Classes.txt");
a_file<<"Second\nThird\nFourth";
a_file.close();
First* MyClass = new Second;
MyClass->MyFunc();
delete MyClass;
std::cin.get();
return 0;
}
Now I just want it to read each line in "Classes.txt" Instead of me saying "new Second"
EDIT:ermmm I was talking to a friend and he told me this isn't the type of polymorphism I'm looking for, oh well, it was a learning experience right?