
笔试面试
sxyaxy
这个作者很懒,什么都没留下…
展开
-
C++标准模板库分析之三
一、关联容器分为:集合(set)、多重集合(multiset),映射(map),多重映射(multimap)集合和多重集合提供了数值集合的操作,头文件映射和多重映射提供了与关键字相关联的映射值,头文件二、映射map原创 2013-10-06 15:54:57 · 576 阅读 · 0 评论 -
【STL】remove算法猜测
一、基本解析 /* nVector = { 1 2 3 4 5 6 6 5 4 3 2 1 }*/remove(nVector.begin(),nVector.end(),3) //移除数据3/* 当p1指向第一个3时,用p2则判断后面不是3的数据,覆盖第一个3,这时,把p1指向下一个要被覆盖的数据 当p2找到的是3,则将后面的数据原创 2014-01-09 18:56:03 · 590 阅读 · 0 评论 -
【STL】Vector类最简单实现
一、Vector类简单实现templateclass myvector{public: typedef T value_type; typedef value_type* iterator;public: T a;public: myvector():a(0){ }public: iterator rev_data() { return原创 2014-01-01 12:03:45 · 810 阅读 · 0 评论 -
【模板】C++函数模板之静多态和动多态
一、静多态class A{public: static void draw() { }};templatevoid draw(){ Object::draw();}void main(int argc, char* argv[]){ draw(); //函数模板的使用}二、动多态 指C++虚函数所原创 2014-01-06 21:22:18 · 1099 阅读 · 0 评论 -
【题目】C++字符串和指针和Strlen()
1、字符串指针char str1[] = "abc";char str2[] = "abc";coutconst char str3[] = "abc";const char str4[] = "abc";coutconst char *str5 = "abc";const char *str6 = "abc";coutchar *str7原创 2014-01-04 20:21:37 · 1037 阅读 · 0 评论 -
【题目】C++异常处理分析
void fun(){ try { cout<<"除零try"<<endl; int zero = 0; int f=1/zero; } catch(int ) { }}int main(int argc, char* argv[]) { try //如果没原创 2014-01-10 12:37:58 · 625 阅读 · 0 评论 -
【题目】C++拷贝构造函数与C++临时对象
一、C++浅拷贝二、C++深拷贝三、C++临时对象参考:1、C++拷贝构造函数(深拷贝、浅拷贝)2、C++拷贝构造函数和赋值操作3、02类与对象(5)-拷贝构造4、拷贝构造函数原创 2014-01-07 18:49:53 · 893 阅读 · 0 评论 -
C++模板
一、函数模板定义如下:template 返回值类型 函数名(形参表)前面是模板定义,后面是普通函数实例:template T max(T a, T b){ return a>b ? a:b;}typename T是类型作为参数,放在中,T可以是int , long , double等二、类模板定义如下:template cla原创 2013-10-06 20:13:40 · 506 阅读 · 0 评论 -
C++模板编译
一、包含编译模型(编译器一般支持)max.h中定义模板函数,再#include "max.cpp"实现文件max.hmax.cpp二、分离编译模型 export template Type sum(Type t1, Type t2){}原创 2013-10-06 21:21:28 · 498 阅读 · 0 评论 -
C++标准模板库分析之一
一、标准模板库二、容器类(顺序容器、关联容器、容器适配器)三、顺序容器vector(向量)类似于数组,其定义在头文件list(列表)类似于双向链表,其定义在头文件deque(双端队列)由双端队列组成,定义在中原创 2013-10-06 14:19:50 · 565 阅读 · 0 评论 -
代码学习
[ code=C/C++ ]main(){ printf("Hello world!");}[ /code]void main(){ cout<<hahha;}原创 2013-09-28 13:38:25 · 417 阅读 · 0 评论 -
【题目】C++中enum分析
基本代码如下:enum color_sets{blue,red,yellow};int main(int argc, char* argv[]){ color_sets current_color = red;//red =1 if(current_color == red) { cout<<"sizeof()="<<sizeof(color_sets)<<endl原创 2014-01-01 12:20:48 · 689 阅读 · 0 评论 -
【题目】static_cast在ATL当中的应用
一、dynamic_cast的应用class Base{public: virtual void OutPut1(){ cout<<"Base"<<endl; }};class Derived1:public Base{public: void OutPut1(){ cout<<"De1"<<endl; }};class Derived2:public原创 2014-01-01 21:50:01 · 1136 阅读 · 0 评论 -
【题目】数组初始化分析
一、一维数组 int a[10] = {0,1,2}; //后面自动初始化为0int a[]={0,1,2}; //3个元素二、二维数组int a[3][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11}}; //标准形式int a[3][4] = {0,1,2,3,4,5,6,7,8,9,10,11}; //在一个大括号内赋值原创 2014-01-06 13:39:09 · 542 阅读 · 0 评论