CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2015
    Posts
    500

    Override the baseclass function

    hello,

    In the base class, i have the following function (this is all in legacy code)

    virtual const std::safemap<int, LPUMTSCELL>& GetUMTSCellList() = 0;

    I am trying to create a new derived class, i am not using the above function. i just want to write a dummy override function. This is to enable instantiating the derived class.

    Code:
    	const safemap<int, LPUMTSCELL> GetUMTSCellList() 
    	{	std::safemap<int, LPUMTSCELL> t; 
            LPUMTSCELL cell;
    		t.insert(std::make_pair(1,cell));
    
    		return t;
    	}
    Then i am getting the following error:
    \TACPlanResultWizard.h(33,33): error C2555: 'TACPlanResultWizard::GetUMTSCellList': overriding virtual function return type differs and is not covariant from 'CWizBasePropSheet::GetUMTSCellList'

    I just want to write a override function for test prupose. Please could you help with this compilation error ?

    thankyou very much
    pdk

  2. #2
    Join Date
    Jan 2009
    Posts
    399

    Re: Override the baseclass function

    const safemap<int, LPUMTSCELL> GetUMTSCellList() from derived implementation is different from

    const safemap<int, LPUMTSCELL>& GetUMTSCellList() = 0;

    See '&' from declaration of base class.
    Last edited by mesajflaviu; December 7th, 2020 at 02:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured