drhejw 2022-08-21 11:27 采纳率: 50%
浏览 96
已结题

VC6下报错illegal member initialization: 'CChartLabel' is not a base or member

问题遇到的现象和发生背景

仅仅在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>
{
我想要达到的结果

在绘制的曲线上增加文本标签

  • 写回答

2条回答 默认 最新

  • 来灵 2022-08-21 20:10
    关注

    demo程序下载下来没VS工程文件?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月1日
  • 已采纳回答 8月24日
  • 修改了问题 8月23日
  • 修改了问题 8月23日
  • 展开全部

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击