![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 75
ZDF0414
这个作者很懒,什么都没留下…
展开
-
顺序表
#include using namespace std; typedef int DataType; class SeqList { public: SeqList() :_array(new DataType[3]) , _size(0) , _capicity(3) {} SeqList(DataType *array, DataType size, DataType c原创 2015-08-26 15:26:40 · 453 阅读 · 0 评论 -
【C++】指针&引用的区别
引用和指针的区别和联系 引用只能在定义时初始化一次,之后不能改变指向其它变量(从一而终);指针变量的值可变。引用必须指向有效的变量,指针可以为空。sizeof指针对象和引用对象的意义不一样。sizeof引用得到的是所指向的变量的大小,而sizeof指针是对象地址的大小。指针和引用自增(++)自减(--)意义不一样。相对而言,引用比指针更安全。 指针比引用更灵活,但是也更危险。使用指原创 2015-10-13 19:37:27 · 797 阅读 · 0 评论 -
【C++】模拟string类的实现(string 类的深拷贝)
#define _CRT_SECURE_NO_WARNINGS #include using namespace std; class String { public: String() :_pstr(new char[1]) { _pstr[0] = '\0'; } String(char *pstr) :_pstr(new char[strlen(pstr) + 1])原创 2015-08-26 15:24:37 · 381 阅读 · 0 评论 -
【C++】强制类型转换(static_cast,reinterpret_cast,const_cast,dynamic_cast,explicit)
强制类型转换关闭或挂起了正常的类型检查,要慎用: (1):static_cast: static_cast用于(非多态)相关类型的转换(静态转换),即可用于编译器隐式执行的任何类型转换 int i = 12; double d = static_cast(i); (2):reinterpret_cast:不相关类型间的强制转换,例子如下: typedef void(*F原创 2015-10-15 19:18:18 · 696 阅读 · 0 评论 -
【C++】双向链表
#include using namespace std; typedef int DataType; class LinkNode { public: LinkNode(const DataType &x) :_data(x) , _prev(NULL) , _next(NULL) {} friend class sList; private: DataType _data;原创 2015-09-02 17:03:26 · 361 阅读 · 0 评论 -
【C++】String_COW(写时拷贝)
//第一种 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; class String { public: String() :_str(new char[1]) , _pRefCount(new int(1)) { _str[0] = '\0'; } String(char *str) :_str(原创 2015-09-02 16:54:47 · 879 阅读 · 0 评论 -
【C++】单链表的基本操作
//头尾相连的单链表 #include using namespace std; typedef int DataType; struct LinkNode { DataType _data; LinkNode *_next; LinkNode(const DataType &x) :_data(x) , _next(NULL) {} }; class sList { publi原创 2015-08-26 15:34:58 · 528 阅读 · 0 评论 -
【C++】菱形虚拟继承(内存布局)
菱形虚拟继承的模式 class A; class B : virtual public A; class C : virtual public A; class D : public B , public c; 单一的虚拟继承 引例一: class Base { private: int _a; }; class Derived : virtual public Bas原创 2015-10-13 18:50:17 · 805 阅读 · 0 评论 -
【C++】万年历(时间计数器)
/****************************************************************************************** Date.hpp: Copyright (c) Bit Software, Inc.(2013), All rights reserved. Purpose: 声明并实现一个万年历类【腾讯面试题】 Author:原创 2015-08-26 15:30:51 · 703 阅读 · 0 评论 -
复数类
//// 实现一个复数类,实现以下成员函数 //class Complex //{ //public: // // 带缺省值的构造函数 // Complex(double real = 0, double image = 0); // // 析构函数 // ~Complex(); // // 拷贝构造函数 // Complex(const Complex& d); // // 赋值运算符重载 //原创 2015-08-26 15:22:57 · 398 阅读 · 6 评论 -
大数运算
在进行大数运算的时候,因考虑到内存问题,所以直接采用算术运算的逻辑对数据进行处理,必定会导致结果的溢出,而无法保证所得结果的正确性。 为了避免上述情况,在数据运算过程中,有时需采用字符串模拟数据的运算,从而提高结果的可靠性。 //Bigdata.h #ifndef BIG_DATA_H #define BIG_DATA_H #include using namespace std; #i原创 2016-03-31 09:37:08 · 793 阅读 · 0 评论