#include "stdafx.h"
#include <conio.h>
class a
{
};
class b : public a
{
public:
void testb(void)
{
printf("\nhello!\n");
}
};
class c
{
public:
void testc(void)
{
m_p = new a;
((b*)m_p)->testb();//明确告诉编译器,转换类型
}
private:
a* m_p;
};
int _tmain(int argc, _TCHAR* argv[])
{
c cc;
cc.testc();
getch();
return 0;
}
#include <conio.h>
class a
{
};
class b : public a
{
public:
void testb(void)
{
printf("\nhello!\n");
}
};
class c
{
public:
void testc(void)
{
m_p = new a;
((b*)m_p)->testb();//明确告诉编译器,转换类型
}
private:
a* m_p;
};
int _tmain(int argc, _TCHAR* argv[])
{
c cc;
cc.testc();
getch();
return 0;
}