C++编程思想 第1卷 第7章 函数重载与默认参数 选择重载还是默认参数 两个都选

//: C07:Mem2.h
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
#ifndef MEM2_H
#define MEM2_H
typedef unsigned char byte;

class Mem {
  byte* mem;
  int size;
  void ensureMinSize(int minSize);
public:
  Mem(int sz = 0);
  ~Mem();
  int msize();
  byte* pointer(int minSize = 0);
}; 
#endif // MEM2_H ///:~

设计类时,重要的是类的接口
如果产生的类容易使用和重用,就说明成功了
如果有必要,总是可以为了效率而作适当的调整

猜你喜欢

转载自blog.csdn.net/eyetired/article/details/81142699