问题遇到的现象和发生背景
仅仅在ChartCtrl 官方例子ChartDemoDlg.cpp 365行后面增加一行CreateBalloonLabel,就报错。不加编译运行都没问题
运行结果及报错内容
运行环境是vc6、win10
ChartDemoDlg.cpp
f:\chartdemo\chartctrl\chartballoonlabel.inl(29) : error C2955: 'CChartLabel' : use of class template requires template argument list
f:\chartdemo\chartctrl\chartlabel.h(118) : see declaration of 'CChartLabel'
d:\microsoft visual studio 6\vc98\include\xtree(36) : while compiling class-template member function '__thiscall CChartBalloonLabel<struct SChartXYPoint>::CChartBalloonLabel<struct SChartXYPoint>(class CChartCtrl *,class CChartSerieBase<stru
ct SChartXYPoint> *)'
f:\chartdemo\chartctrl\chartballoonlabel.inl(30) : error C2512: 'CChartLabel<struct SChartXYPoint>' : no appropriate default constructor available
d:\microsoft visual studio 6\vc98\include\xtree(36) : while compiling class-template member function '__thiscall CChartBalloonLabel<struct SChartXYPoint>::CChartBalloonLabel<struct SChartXYPoint>(class CChartCtrl *,class CChartSerieBase<stru
ct SChartXYPoint> *)'
f:\chartdemo\chartctrl\chartballoonlabel.inl(30) : error C2614: 'CChartBalloonLabel<struct SChartXYPoint>' : illegal member initialization: 'CChartLabel' is not a base or member
d:\microsoft visual studio 6\vc98\include\xtree(36) : while compiling class-template member function '__thiscall CChartBalloonLabel<struct SChartXYPoint>::CChartBalloonLabel<struct SChartXYPoint>(class CChartCtrl *,class CChartSerieBase<struct SChartXYPoint> *)'
问题相关代码,请勿粘贴截图
demo是从这里下载的:https://www.codeproject.com/Articles/14075/High-speed-Charting-Control
修改了的地方
ChartDemoDlg.cpp :
pSeries->SetPoints(XValues,YValues,NumberPoints); //这行代码是原有的, 第365行。
pSeries->CreateBalloonLabel(10, _T("label test"));//仅仅增加了 这一行代码。其他哪里都没动。
CreateBalloonLabel在基类ChartSerieBase.inl的定义:
template<class T>
CChartBalloonLabel<T>* CChartSerieBase<T>::CreateBalloonLabel(unsigned uPointIndex,
const TChartString& strLabelText)
{
ASSERT(uPointIndex<GetPointsCount());
CChartBalloonLabel<T>* pToReturn = new CChartBalloonLabel<T>(m_pParentCtrl, this);
pToReturn->SetLabelText(strLabelText);
AttachCustomLabel(uPointIndex, pToReturn);
return pToReturn;
}
报错的地方ChartBalloonLabel.inl :
template<class PointType>
CChartBalloonLabel<PointType>::CChartBalloonLabel(CChartCtrl* pParentCtrl,
CChartSerieBase<PointType>* pParentSeries)
: CChartLabel(pParentCtrl, pParentSeries), m_bRoundedRect(true) //Ln29
{
m_colBackground = RGB(255,255,225);
m_colLine = RGB(255,255,255);
m_colBorder = RGB(0,0,0);
}
ChartBalloonLabel.h的定义:
template <class PointType>
class CChartBalloonLabel : public CChartLabel<PointType>
{
我想要达到的结果
在绘制的曲线上增加文本标签