2008年6月20日
摘要: 写了几个实现差不多功能的函数,然后发现它们的唯一区别就是形参或返回值的数据类型不一样,我很懊恼,又是大量代码重复.幸运的是,C++提供了模板功能,可以很方便地解决这个问题. 题目:编写一个函数模板,棘手表示未知类型迭代器的一对值,找出在序列中出现最频繁的值. 1// 16.12 2#include 3#include 4#include 5#include ... 阅读全文
posted @ 2008-06-20 19:52 allen182 阅读(341) 评论(0) 推荐(0)
  2008年6月16日
摘要: 问题始于C++ primer(4) P406.C++支持两种初始化形式:直接初始化和复制初始化.直接初始化直接调用与实参匹配的构造函数,复制初始化总是调用复制构造函数 .书上说复制初始化使用=符号,而直接初始化将初始化式放在圆括号里.个人认为说的不太对或者是自己没看明白.下面是一段测试程序: 1//初始化时发生了什么 2#include 3#include 4#include ... 阅读全文
posted @ 2008-06-16 19:59 allen182 阅读(291) 评论(2) 推荐(0)
摘要: 一年前在自己qq空间里写的,现在SQL还算熟练.多亏了这篇文章让自己开了个好头 发表于:2007年7月31日 0时40分18秒阅读(27)评论(3) 举报本文链接:http://user.qzone.qq.com/64905449/blog/8 初学动态SQL 统计汇总可以在数据库层面做,也可以在应用程序层面做 但按一般的分层思想,个人认为应该在数据库中完成 而且从统计汇总的复杂上说,更应该在数... 阅读全文
posted @ 2008-06-16 16:54 allen182 阅读(352) 评论(0) 推荐(0)
  2008年6月15日
摘要: 1//14.8.1 将函数对象用于标准库算法 2#include 3#include 4#include 5#include 6#include 7#include "hh.h" 8using namespace std; 9 10// 长度大于指定值 11class LongerThen{ 12public: 13 LongerThen(int i):iLen... 阅读全文
posted @ 2008-06-15 10:40 allen182 阅读(238) 评论(0) 推荐(0)
  2008年6月13日
摘要: 1//14.5 下标操作符 2#include 3#include 4#include 5#include 6using namespace std; 7 8class Sample{ 9public: 10 Sample(int *p1,int *p2); // 构造函数 11 //Sample& operator[](const size_t); //... 阅读全文
posted @ 2008-06-13 23:02 allen182 阅读(418) 评论(0) 推荐(0)
  2008年6月11日
摘要: 1//13.24 智能指针(使用计数) 主要的已完成 2#include 3#include 4#include 5#include 6using namespace std; 7 8class UseCnt; // 因为HasPtr要用到UseCnt,所以一定要记得先声明 9 10class UseCnt{ 11public: 12 friend cla... 阅读全文
posted @ 2008-06-11 23:51 allen182 阅读(225) 评论(0) 推荐(0)
  2008年6月10日
摘要: 1//13.16-13.19 待完善,还不太明白需求的细节 2#include 3#include 4#include 5#include 6using namespace std; 7 8class Folder; // 要在定义Message前声明Folder,因为定义Messge用到了Folder 9 10class Message{ 11p... 阅读全文
posted @ 2008-06-10 21:45 allen182 阅读(329) 评论(1) 推荐(0)
  2008年6月7日
摘要: 1class Student{ 2public: 3 Student(const string s="10000"):No(s){} 4 virtual void PrintInfo() const 5 { 6 coutPrintInfo();但是执行的行为完全不一样 30 Student *Stu=new Student("1... 阅读全文
posted @ 2008-06-07 17:06 allen182 阅读(290) 评论(0) 推荐(0)