![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++基础
gfgdsg
这个作者很懒,什么都没留下…
展开
-
C++实现String类
#include#include#includeusing namespace std;class String{private: char *str; int len; static int num_strings;public: String(); String(const char *s); String(const String &); ~String();原创 2014-07-22 17:55:35 · 364 阅读 · 0 评论 -
友元实现复数运算
#includeusing namespace std;class complex{private: double a; double b;public: complex(); complex(double ax,double bx); complex operator+(const complex & com); complex operator-(const comple原创 2014-07-22 17:54:11 · 570 阅读 · 0 评论 -
找到两个字符串集合的交集
set SplitString(string str){ set split; char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); char *temp = strtok(cstr, ","); while (temp) { split.insert(temp); temp = strtok(原创 2014-11-13 11:41:44 · 2867 阅读 · 0 评论 -
大数相加(字符串解法)
#include#include#include#include#include#includeusing namespace std;//大数相加vector Add(vector &left,vector&right){ int mlen, len, i, c = 0; mlen = left.size() > right.size() ? left.size() :原创 2014-12-03 16:45:50 · 534 阅读 · 0 评论 -
C++ 内存分配(new,operator new)
本文主要讲述C++ new运算符和operator new, placement new之间的种种关联,new的底层实现,以及operator new的重载和一些在内存池,STL中的应用。一 new运算符和operator new(): new:指我们在C++里通常用到的运算符,比如A* a = new A; 对于new来说,有new和::new之分,前者位于std原创 2015-03-07 17:25:27 · 458 阅读 · 0 评论