摘要: 之前实现的枚举类enum class虽然达到了当时期望的功能,但现在在用的时候出现了一些问题。比如新定义了一个Token的类,定义如下,class Token{public: Token(){} Token(int tp, string tx) { type = tp; text = tx; } int Type() const { return type; } string Text() const { return text; } friend ostream& operator << ... 阅读全文
posted @ 2012-10-08 18:29 Frandy.CH 阅读(739) 评论(2) 推荐(0) 编辑
摘要: 虽然写过一些C++程序,有类有继承,但对虚函数和多态用的不多,最近想尝试一下多态,却出了些问题。于是不得不重新来学习虚函数与多态。简单的示例程序如下,class Lexer{public: Lexer(){} Lexer(string t){ name = "Lexer"; text = t; } virtual void Print(){ cout << name << ":" << text << endl; }protected: string name; string text;};class Ex 阅读全文
posted @ 2012-10-08 14:38 Frandy.CH 阅读(256) 评论(0) 推荐(0) 编辑