使用class object的指针

Categories: CPP
使用class object的指针略有不同,这是因为class object链接到一组我们可以调用(invoke)的操作行为(operations),举例来说检查fibnacci vector的第二个元素是否为1,我们可能会这么写: if (!fibonacci.empty() && (fibonacci[1] == 1)) 上例中的fibonacci和empty()两字之间的逗号,称为dot成员选择运算符(member selection operator),用来选择想要施行的操作,如果要通过指针来指针来选择操作行为,必须改用arrow成员选择运算符: 由于指针可能未指向任何对象,所以先校验pv是否为非零值 if (pv && pv->empty() && ((*pv)[1] == 1))

函数默认值设置

Categories: CPP
h #include <vector> #include <iostream> using namespace std; void display(const vector<int>&, ostream& = cout); cpp #include "NumericSeq.h" void display(const vector<int> &vec, ostream &os){ for (int ix = 0; ix < vec.size(); ix++){ os << vec[ix] << ' '; } os << endl; } 默认值resolve由最右边进行,如果为某个参数提供了默认值,那么这个参数右侧所有参数必须有默认值 默认值只能指定一次,可以在声明处,可以在函数定义处,由于头文件为函数带来更高的可见度,所以置于函数声明处 (出自Essential C++)

查看机器重启时间

Categories: Linux
who -b 上次启动时间 last reboot 系统启动记录 last reboot |head -1 最后一次启动时间 w 可查看系统已经运行时间 top 也可查看

blob字段插入实例

Categories: Oracle
blob字段插入实例 create table blob_table( id number primary key, blob_cl blob not null ); insert into blob_table values(1,to_blob('11111000011111')); commit; select * from blob_table; update blob_table set blob_cl=to_blob('110010000110011') where id=1; delete from blob_table where id=1; commit;

输出重定向到文件

Categories: Linux
ls > log.log ls >> log.log --不覆盖log.log,追加 cat 1.txt 2> log.log --错误输出到log.log cat 1.txt > log.log 2>&1 --stderr也输出到stdout stdin 0 < stdout 1 1> stderr 2 2>