There is a lot of identical code between our different chart classes. In particular they all have in common a title and two functions called writeAsHTML. Design a base class and extend it for each chart. Draw a UML diagram of the resulting hierarchy. Use getter and setter methods to access the title.
写了一个BaseChart的接口,用于实现chart类的接口,在整合的过程中,又出现了报错:编译器错误 C2259,这个是继承的时候虚函数没有完全 实现导致的,一个个函数的名称,参数和返回值进行对比。
BaseChart.h
#pragma once
#include "stdafx.h"
#include "testing.h"
/*
There is a lot of identical code between our different chart classes. In
particular they all have in common a title and two functions called writeAsHTML. Design a base class and extend it for each chart. Draw a UML diagram
of the resulting hierarchy.
*/
class BaseChart {
public:
/* Virtual destructor */
virtual ~BaseChart() {};
/* Use getter and setter methods to access the title. */
virtual void setTitle(const std::string &title) = 0;
virtual std::string getTitle() = 0;
/* Calculate the payoff of the option given
a history of prices */
virtual void writeAsHTML(std::ostream& out) const=0;
virtual void writeAsHTML(const std::string& file) const=0;
//std::string title;
private:
std::string title;
};
系统当前共有 481 篇文章