c++
wudi_X
学习使人快乐!
展开
-
C++ 用operator实现隐式类型转换
Operator用于C++的运算符重载,同时也可用于隐式类型转换,看下面这个例#include <iostream> template<typename _T> class A { public: A(_T a) : data(a) {} operator _T () { return data; } private: _T data; }; int main() ...原创 2018-03-08 21:32:26 · 1352 阅读 · 0 评论 -
【数据结构】栈实现表达式求值
用栈实现表达式求值,涉及到中、后缀表达式转换的问题。 Expression.h /***************** * Calc_Expression() * 功能: 利用栈实现整数表达式求值 * 输入: 表达式字符串 * 输出: 求值结果 * 作者: wudi_X * 日期: 2018-04-05 *******************/ #ifndef EXPRESSION_H_ #de...原创 2018-04-13 20:41:09 · 4406 阅读 · 0 评论 -
【c++】static关键字
前言 本片博文记录c/c++中static关键字在函数和类中的用途 static在函数中 static关键字出现在函数定义时,表明函数是只对当前文件可见的,其他文件中要包含无法调用该函数,若其他文件声明同名函数时不会引起冲突。 具体例子: // 文件1.hpp,函数前面加static static void func(); // 文件2.hpp,声明同名函数 #includ...原创 2018-07-29 11:30:20 · 183 阅读 · 0 评论