摘要: 转载自:http://www.ibm.com/developerworks/aix/library/au-unix-eclipse/index.htmlBuild UNIX software with EclipseBringing legacy code into a modern IDEChris Herborth (chrish@pobox.com), Freelance, Freelance WriterSummary: Become more productive with your own code and others by utilizing Eclipse's syn 阅读全文
posted @ 2012-01-27 11:24 sharpstill 阅读(2255) 评论(0) 推荐(0) 编辑
摘要: 类似java或python的string的replace方法?string replace( pos ,len , new_str ); C++的string的replace的原始定义的第一个参数起始替换下标,第二个参数是从起始替换下标开始替换的len个字符,第三个参数是new_str.与python的字符串替换略有不同,现在比如我要把str = "Hello world mac"中的mac替换成jobs1. 替换第一次出现的字符串mac(只替换第一次出现的字符串,不是replaceAll):string old_word= "mac";string h 阅读全文
posted @ 2012-01-27 11:17 sharpstill 阅读(799) 评论(0) 推荐(0) 编辑
摘要: 续上一篇《C++模板类(泛型类)学习总结》(网址:http://www.cnblogs.com/sharpstill/archive/2012/01/27/2330059.html),现在问题来了,我建立了一个MotherStudent<Student*>* mother_std 的指针,我想要析构这个MotherStudent里的children(vector<T>,该T是一个Student*指针),我如何析构一个装满指针的容器?贴出上次修改过的博文里的代码如下:(注意红笔)int _tmain(int argc, _TCHAR* argv[]){ // Mother 阅读全文
posted @ 2012-01-27 11:11 sharpstill 阅读(2393) 评论(1) 推荐(0) 编辑
摘要: 调试了一下午,发现用C++写模板方法真是有不少值得注意的地方,不是一般的麻烦,没点经验总结真是不行的。首先,写模板类(template class),这个在java叫作泛型类,需要注意几点,在写泛型类时.h头文件和实现(.cpp)不能分离,也就是说,关于泛型类/模板类的所有逻辑都 要写在一个文件中,我的做法是将类的函数体和函数原型都写入头文件,而省去.cpp的implement的文件。头文件如下:#ifndef MOTHER_STUDENT_H#define MOTHER_STUDENT_H#include "Student.h"#include <vector> 阅读全文
posted @ 2012-01-27 11:10 sharpstill 阅读(6662) 评论(0) 推荐(0) 编辑