
C++
文章平均质量分 52
cyendra
Azarath Metrion Zinthos
展开
-
Operator overloading
Common operators to overload Most of the work in overloading operators is boiler-plate code. That is little wonder, since operators are merely syntactic sugar, their actual work could be done by (a转载 2014-06-24 14:34:19 · 767 阅读 · 0 评论 -
C++语法笔记
【explicit】 只对构造函数起作用,用来抑制隐式转换。原创 2014-04-17 08:51:00 · 530 阅读 · 0 评论 -
Why can templates only be implemented in the header file?
Quote from The C++ standard library: a tutorial and handbook: The only portable way of using templates at the moment is to implement them in header files by using inline functions. Why is转载 2014-06-23 18:20:06 · 807 阅读 · 0 评论 -
Effective C++ 笔记一 让自己习惯C++
条款01:视C++为一个语言联邦 C++是个多重范型编程语言,一个同时支持面向过程形式、面向对象形式、函数形式、泛型形式、元编程形式的寓言。 将C++视为几个子语言: 传统C:区块、语句、预处理器、内置数据类型、数组、指针。没有模板、没有异常、没有重载。 面向对象C++:类(包括构造函数析构函数)、封装、继承、多态、虚函数。 Template C++:泛型编程、模板元原创 2014-08-25 17:36:49 · 694 阅读 · 0 评论 -
虚函数的验证 = =
#include <iostream> #include <cstdlib> #include <algorithm> #include <cstdio> #include <cstring> #include <set> using namespace std; class Base { public: virtual void f() { cout<< "Base::f" << endl原创 2015-03-20 12:28:46 · 541 阅读 · 0 评论 -
用皮亚诺公里做了一个C++模板元编程语言
1-不支持负数 2-只能处理100以内的整数 3-只有整型和布尔值两种数据类型 4-有bug 5-支持常见的函数式编程如i0, i1, …, i9, i10 — 表示数字0到10Succ — 后继 Pred — 前驱Add#pragma once#include <iostream>namespace raven { /********************************原创 2015-05-08 22:15:54 · 1016 阅读 · 0 评论 -
用C++实现LINQ的一些思路
假设现在有一个问题:对一个给定的数组A,计算其中元素的平方和。 熟悉命令式编程的人很快就能写出这样的代码: int A[] = { 1, 2, 3, 4, 5 }; int sum = 0; for (auto it = begin(A); it != end(A); it++) { sum += (*it) * (*it); } cout <原创 2015-04-30 16:55:59 · 1758 阅读 · 0 评论 -
GCC编译选项
-E 预编译 -S 编译到汇编 -c 编译但不连接 -o 输出文件名 -g 生成供调试用的可执行文件 -s 不含符号信息 -O 编译优化 -O1 -O2 -O3 -w 关闭所有警告信息 -W 开启额外的警告信息 -Wall 警告全开 -Werror 所有的警告都为编译错误 -lxxx 指定函数库xxx -L 指定函数库所在文件夹 -I 指定头文件所在文件夹 -includ原创 2015-05-10 20:57:27 · 871 阅读 · 0 评论