
C/C++ 试题
lishengyaupc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
一个数组中,除两个不同的数字外,两两相同,找到两个不同的数字,输出
#include <iostream> /* 一个数组中,除两个不同的数字外,两两相同,找到两个不同的数字,输出 * 数组的数,两两相与,然后找到第一个为1的比特位,依据在该位上数值的不同,按位与操作,分成两类 * 每一类都两两相与,得到两个不同的数。 */ using namespace std; int first_1_bite(int a) { int ...原创 2019-03-25 14:59:55 · 997 阅读 · 0 评论 -
判断两个ip地址是否在同一子网内
#include <iostream> #include <cstring> #include <cstdlib> using namespace std; bool Addr_to_Array(char* addr, int* array) { bool ret = (addr != NULL ); char* sub = NULL; ...原创 2019-03-25 15:04:51 · 953 阅读 · 0 评论 -
旋转数组的打印,逆时针增大
狄泰软件课堂笔记 #include <iostream> /* 旋转数组的打印,逆时针增大 */ using namespace std; #define N 5 class Spin_Matrix { private: int Matrix[N][N]; struct pos { int dx; int ...原创 2019-03-25 21:21:05 · 255 阅读 · 0 评论 -
笔试题
1. 下面的代码输出什么?为什么? #include <iostream> #include <malloc.h> using namespace std; class A { private: static int c_count; public: A() { c_count++; } ~A() { c_count--;...原创 2019-03-25 21:30:42 · 142 阅读 · 0 评论 -
不要重定义继承来的缺省参数值
virtual函数是动态绑定(后期绑定),缺省参数是静态绑定(前期绑定) 对象的静态类型:就是它在被声明时所采用的类型; 对象的动态类型:目前所指对象的类型。父类指针,指向了子类对象,动态类型就是子类类型 #include <iostream> using namespace std; class A { public: A() { cout &l...原创 2019-03-25 22:13:13 · 212 阅读 · 0 评论 -
拷贝构造函数
1)对象作为函数参数,以值传递的方式 2)函数返回值为对象 3)用对象给另一个对象初始化 #include <iostream> using namespace std; class Test { int m_i; int m_j; public: Test() { cout<<"Test()"<<endl; } Test...原创 2019-03-26 16:31:24 · 138 阅读 · 0 评论 -
虚析构函数
#include <iostream> using namespace std; class Base { public: Base() { cout << "Base()" << endl; } virtual ~Base() { cout << "~Base()" << endl; } }; clas...原创 2019-09-11 23:11:39 · 133 阅读 · 0 评论