Professional C++读书随笔(2)

Professional C++读书随笔(2)
C++ 中的抽象类其实就是纯虚函数组成的类,如下所示:
class  SpreadsheetCell
{
public:
    SpreadsheetCell();
    
virtual ~SpreadsheetCell();
    
virtual void set(const std::string& inString) = 0;
    
virtual std::string getString() const = 0;
}
;
An abstract class provides a way to prevent other code from instantiating an object directly, as opposed to one of its subclasses.
抽象类只能被扩展,不能创建一个与他某个子类相冲突的对象实例!

---------------------------------------------------------
专注移动开发
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian

你可能感兴趣的:(Professional C++读书随笔(2))