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

    [RESOLVED] Issue with ABCs - ERROR C2259

    Hi,

    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.
    Lapin

    //Abstract class definition

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

    }

    //Derived class definition

    class xlMMublic xlINSTRUMENTS
    {
    private:
    ...
    public:
    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
    Location
    Otaki, New Zealand
    Posts
    303

    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.

    Code:
    xlINSTRUMENTS *pABC = new xlMM(...);
    Regards
    Alan

  3. #3
    Join Date
    May 2007
    Posts
    9

    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
  •  





Click Here to Expand Forum to Full Width

Featured