C++
文章平均质量分 70
zgw285763054
这个作者很懒,什么都没留下…
展开
-
【C++】顺序表
#pragma once#include#include using namespace std;typedef int DataType;class SeqList{public: SeqList() :_array(NULL) ,_size(1) ,_capacity(1) {} SeqList(DataType* array, size_t size)原创 2016-04-25 23:01:14 · 541 阅读 · 0 评论 -
【C++】输入输出运算符的重载
#include using namespace std;class Date{ friend ostream& operator<<(ostream& os, Date& d); friend istream& operator>>(istream& is, Date& d);public: Date(int year = 1900, int month = 1, int day原创 2016-04-13 20:45:05 · 361 阅读 · 0 评论 -
【C++】日期类
日期类和日期计算器原创 2016-04-14 23:05:40 · 252 阅读 · 0 评论 -
【C++】模拟实现new[]和delete[]
定位new表达式是在已分配的原始内存空间中调用构造函数初始化一个对象。new (place_address) typenew (place_address) type(initializer-list)place_address必须是一个指针,initializer-list是类型的初始化列表。#include using namespace std;clas原创 2016-04-17 16:00:41 · 350 阅读 · 0 评论 -
【C++】String类
#include using namespace std;class String{public: //String() // :_str(new char[1]) //{ // _str[0] = '\0'; //} String(char* str = "")//构造函数 :_str(new char[strlen(str)+1]) { strcpy(_str原创 2016-04-18 14:20:48 · 347 阅读 · 0 评论 -
【C++】复数类
#include using namespace std;class Complex{public: //构造函数 Complex(double real = 0.0, double image = 0.0) :_real(real) ,_image(image) {} //拷贝构造函数 Complex(const Complex& c) :_real(c._re原创 2016-04-19 20:42:51 · 319 阅读 · 0 评论 -
【C++】引用计数
#include using namespace std;class String{public: String(const char* str) :_str(new char[strlen(str) + 5]) { _str += 4; strcpy(_str, str); _GetRefCount(_str) = 1; } String(const原创 2016-04-22 13:06:37 · 355 阅读 · 0 评论