c++中human* p = new man;p->Disp();题目
2012-05-21 22:15
204 查看
#include "stdafx.h"
#include <iostream>
using namespace std;
class human
{
public:
~human()
{
cout<< "human over......" <<endl;
}
void Disp()
{
cout <<"human disp......" <<endl;
}
};
class man : public human
{
public:
~man()
{
cout << "man over ......." <<endl;
}
void Disp()
{
cout << "man disp......." << endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
human* p = new man;
p->Disp();
delete p;
return 0;
}
输出结果: human disp......
human over......
#include <iostream>
using namespace std;
class human
{
public:
~human()
{
cout<< "human over......" <<endl;
}
void Disp()
{
cout <<"human disp......" <<endl;
}
};
class man : public human
{
public:
~man()
{
cout << "man over ......." <<endl;
}
void Disp()
{
cout << "man disp......." << endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
human* p = new man;
p->Disp();
delete p;
return 0;
}
输出结果: human disp......
human over......
相关文章推荐
- C++封装SQLite实例<三>
- C++学习:关于“std::vector<Type>::iterator”的一个错误
- C++中#include<iostream.h>和#include<iostream>
- C/C++中判断某一文件或目录是否存在&lt;转&gt;
- C++-->类
- &lt;More Effective C++&gt;笔记--其他杂项
- c++builder error:在button1click中,不调用别人的线程时可以运行 Form1->suiButton1->Visible = false;等重绘控件,但是调用后就不可以重绘
- C++中#include<string>的问题
- C++基础<02>—变量和基本类型
- { 容器map }C++ <map>
- c++中箭头操作符(->) VS 点操作符(.)
- <<Thinking in C++>>读中感
- <C/C++基础>九度OJ题目1050--1100解题练习(三)
- c++中string常用函数整理<引用>
- C++ 箭头-> 双冒号:: 点号.操作符区别
- 学习C++ -> 向量(vector)
- C++ FAQ Lite[15]--通过 <iostream> 和 <cstdio>输入/输出(新)
- mysql connector c++ {realStr=<读取字符串的字符时出错。> }
- C++ 中dynamic_cast<>的用法
- 打印数字金字塔 <Introduction to Programming with C++ comprehensive Version :Page_89>