+ Reply to Thread
Results 1 to 2 of 2

Thread: In C++, what is cannot instantiate abstract class due to following members error?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    27

    In C++, what is cannot instantiate abstract class due to following members error?

    Below code does not compile:

    Code:
    class CMyClass
    {
    public:
    	CMyClass() {} 
    
    	~CMyClass() {}
    
    	virtual GetData() = 0 ;
    } ;
    
    void Func1()
    {
    	CMyClass objMyClass ;
    }
    What is the issue?

    Please help.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    29
    You cannot create an instance of an abstract base class (ABC.)

    An ABC is a class where one of the method is declared as pure virtual method and does not have its implementation.

    Either you derive a new class (having all the method implemented) from ABC or implement all the method should resolve the issue.

    Enjoy!

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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