搜狗笔试题
2015-09-26 17:26
218 查看
#include <iostream> #include <stdio.h> using namespace std; int main() { int pid; int num = 1; pid = fork(); if(pid > 0) { num ++; cout<<num<<endl; cout<<&num<<endl; cout<<endl; } else if(pid ==0) { cout<<num<<endl; cout<<&num<<endl; cout<<endl; } cout<<num<<endl; getchar(); return 0; }
// sougoutest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; class A { public: virtual void test(float a){cout<<'1';} }; class B:public A { public: void test(int b){cout<<'2';} }; int _tmain(int argc, _TCHAR* argv[]) { A *a = new A; B *b = new B; a= b; a->test(1.1); a->test(1); b->test((float)1.1);//调不到父类的test?为何 b->test(1); ((A*)b)->test(1);//为何这样可以调用到父类? return 0; }
相关文章推荐
- [Cocos2d塔防游戏开发]Cocos2dx-3.X完成塔防游戏《王国保卫战》--防御塔(一)
- @property的几个参数说明
- 全局变量和局部变量的存储位置
- Android常见出错:OutOfMemoryError与ArrayIndexOutOfBoundsException
- Samba网络文件共享服务介绍
- HashMap与Hashtable的区别
- 15分钟搞定iOS9 Quick Actions
- uml视频之uml概述二
- NET Runtime Optimization Service 1101 错误的解决方法
- 小议Java的源文件的声明规则以及编程风格
- Linux tar
- C# 异步编程小结
- Genymotion模拟
- 或||的计算
- C#向指定路径写入文件
- 二叉树层次遍历和深度遍历
- java反射(relection)
- JAVA基础学习(十六)--集合三-Map、HashMap,TreeMap与常用API
- 支付宝个人收款二维码的创建
- sql 2012 与java连接的类