questface.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 35 行

H
35
字号
#ifndef _QUESTIONTERFACE_H
#define _QUESTIONTERFACE_H

// abstract base class for quiz questions
// derived classes MUST implement four functions:
//
// void Ask()        to ask the question
// string Answer()   to return the answer
// bool IsCorrect(s) to tell if an answer s is correct
// void Create()     to create a new question
//
// This class conforms to the naming conventions
// of quiz questions in "A Computer Science Tapestry" 2e

#include <string>
using namespace std;

class Question
{
  public:
    virtual ~Question() { }   // must implement destructor, here inline
    
    // accessor functions
    
    virtual bool    IsCorrect(const string& answer)  const = 0;
    virtual string  Answer()                         const = 0;
    virtual void    Ask()                            const = 0;
    
    // mutator functions
    
    virtual void Create() = 0;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?