C++ 多态演示
C++ 多态演示
http://www.blue1000.com/bkhtml/c151/2010-11/69751.htm
// father.cpp : Defines the entry point for the console application.
//我在学习的过程中发现的问题。
#include "stdafx.h"
#include <IOSTREAM>
using namespace std;
class father
{
public:
virtual void show();
};
inline void father::show()
{
cout<<"I am father"<<endl;
}
void hello(father* fp)
{
fp->show();
}
int main(int argc, char* argv[])
{
// father f; 这里,写法有很多。
// father *f = new father;
father fp;
father *f = &fp;
hello(f); 到这里。写法有很多。
printf("Hello World!\n");
return 0;
}