HI

I have a class className which is an abstract class. I am attaching the definition in the code snipet below.

when I am writing the line I am getting an error

error C2259: 'className' : cannot instantiate abstract class

From this error I have understood that we cannot create an instance of an abstract class

But when I make the object of the class i.e.
className obj.
and try to access the public function initState().

I am getting an error

"object reference is not set"

How to resolve this problem

class ClassName : public Class2, public Class3{	
	virtual ~ClassName{}		
public:
	virtual void initState ();
protected:
	virtual void clearState ();
}

Regards
Karan

Recommended Answers

All 3 Replies

Provide a small but complete example of code that exhibits your problem.

Your code sample and description is not complete, and the cause of the error is probably in something you haven't shown or described.

Hi

I have a question regarding the abstract class.

If the class contains 5 pure virtual methods then it is necessary to implement all the methods of the class by the derived class.

Regards
Karan

It is necessary for the derived class to override all inherited pure virtual functions, otherwise the derived class remains an abstract class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.