CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: [RESOLVED] Issue with ABCs - ERROR C2259

  1. #1
    Join Date
    May 2007

    [RESOLVED] Issue with ABCs - ERROR C2259


    I am getting trouble to make my ABC working.

    I can not compile my dll as soon as I use an ABC. The compiler tells me error C2259: 'xlINSTRUMENTS' : cannot instantiate abstract class

    I have searched around and I thought it was a signature problem but it does not look like since the 2 functions are really the same.

    I thouth also it was a problem of object creation but it is unlikely also.
    In order to create my xlMM object, I write the following line:

    xlINSTRUMENTS * abc = new xlMM(..........);
    with xlMM(..........) being the correct constructor.

    or xlINSTRUMENTS abc = xlMM( ..... ) if I want to create the object it self and not a pointer.

    I am under Visual studio .NET 2003 and I am trying to compile a Multithreaded dll.
    I have enclosed the code at the end in order to be complete.

    Any help would be greatly appreciated.

    //Abstract class definition

    class xlINSTRUMENTS
    std::string Name;
    virtual double RetrieveInstrument( const double & ,const double & ) const = 0 ;


    //Derived class definition

    class xlMMublic xlINSTRUMENTS
    virtual double RetrieveInstrument(const double & ,const double & ) const ;

    //virtual fonction definition
    double xlMM::RetrieveInstrument( const double &InputHeader ,const double &InputValue ) const
    return InputHeader;

  2. #2
    Join Date
    Jul 2001
    Otaki, New Zealand

    Re: Issue with ABCs - ERROR C2259

    An ABC acts solely as a base class for inherited classes. You cannot instantiate an ABC - you must instantiate one of the derived classes using new and assign it to a pointer to the base ABC.

    xlINSTRUMENTS *pABC = new xlMM(...);

  3. #3
    Join Date
    May 2007

    Resolved Re: Issue with ABCs - ERROR C2259

    Thanks Alan.

    I should have thought a little bit longer.
    Anyway case solved.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)