![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++ 试题
lishengyaupc
这个作者很懒,什么都没留下…
展开
-
一个数组中,除两个不同的数字外,两两相同,找到两个不同的数字,输出
#include <iostream> /* 一个数组中,除两个不同的数字外,两两相同,找到两个不同的数字,输出 * 数组的数,两两相与,然后找到第一个为1的比特位,依据在该位上数值的不同,按位与操作,分成两类 * 每一类都两两相与,得到两个不同的数。*/using namespace std;int first_1_bite(int a){ int ...原创 2019-03-25 14:59:55 · 938 阅读 · 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 · 878 阅读 · 0 评论 -
旋转数组的打印,逆时针增大
狄泰软件课堂笔记#include <iostream>/* 旋转数组的打印,逆时针增大 */using namespace std;#define N 5class Spin_Matrix{private: int Matrix[N][N]; struct pos { int dx; int ...原创 2019-03-25 21:21:05 · 215 阅读 · 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 · 114 阅读 · 0 评论 -
不要重定义继承来的缺省参数值
virtual函数是动态绑定(后期绑定),缺省参数是静态绑定(前期绑定)对象的静态类型:就是它在被声明时所采用的类型;对象的动态类型:目前所指对象的类型。父类指针,指向了子类对象,动态类型就是子类类型#include <iostream>using namespace std;class A{public: A() { cout &l...原创 2019-03-25 22:13:13 · 177 阅读 · 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 · 109 阅读 · 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 · 98 阅读 · 0 评论