compilation issue

S

seema

hi all ,

I am new to C++ programming. Can some body explain reason for this
compilation error,



.../inc/polecache.h", line 339: error #2322: object of abstract class
type
"CPoleCache::CCacheViewImpl" is not allowed:
pure virtual function "IViewObject::Draw" has no overrider
CCacheViewImpl m_View;
/\


I got this compilation error when compiling with "aC++/ANSI C A.06.05"
on
HP-UX 11i. This code was working fine with "aC++/ANSI C A.06.05" before
:)

Thanks,
Seema Rao
 
D

dc

I think u try trying to create instance of abstract class or
derived class that has not implemented the pure virtual fn. of base
class.

It would be better if u can post some snippet of ur source code
 
S

seema

Sorry I mean to say code was working fine with the "aC++/ANSI C
A.5.55". Now as I am trying to upgrade bits to aC++/ANSI C A.06.05
I am getting this error . Any clues?
 
S

Sunil Varma

seema said:
hi all ,

I am new to C++ programming. Can some body explain reason for this
compilation error,



../inc/polecache.h", line 339: error #2322: object of abstract class
type
"CPoleCache::CCacheViewImpl" is not allowed:
pure virtual function "IViewObject::Draw" has no overrider
CCacheViewImpl m_View;
/\
Could you check for the implementation of Draw method in CCacheViewImpl
class.
If it is not there, then you cannot create an object for CCacheViewImpl
class.
I got this compilation error when compiling with "aC++/ANSI C A.06.05"
on
HP-UX 11i. This code was working fine with "aC++/ANSI C A.06.05" before
:)

Thanks,
Seema Rao


Could you post the code of the base and derived classes so that we can
look into it furthur.
 
T

Tomás

seema posted:
hi all ,

I am new to C++ programming. Can some body explain reason for this
compilation error,



../inc/polecache.h", line 339: error #2322: object of abstract class
type
"CPoleCache::CCacheViewImpl" is not allowed:
pure virtual function "IViewObject::Draw" has no overrider
CCacheViewImpl m_View;
/\


I got this compilation error when compiling with "aC++/ANSI C A.06.05"
on
HP-UX 11i. This code was working fine with "aC++/ANSI C A.06.05" before
:)

Thanks,
Seema Rao


Without seeing your code, my guess would be that you've left out an
ampersand in function argument list, eg.:

void Function( CPoleCache::CCacheViewImpl object ) //pass by value

instead of:

void Function( CPoleCache::CCacheViewImpl &object ) //pass by reference


-Tomás
 
S

Simon Elliott

I am new to C++ programming. Can some body explain reason for this
compilation error,



../inc/polecache.h", line 339: error #2322: object of abstract class
type
"CPoleCache::CCacheViewImpl" is not allowed:
pure virtual function "IViewObject::Draw" has no overrider
CCacheViewImpl m_View;
/\

In C++ an abstract class has at least one pure virtual function.

A pure virtual function is a function which is declared in its class
with the suffix "=0". This means that the function is not defined in
its class.

So an abstract class can't be used on its own to create an object. You
have to provide a derived class where all the pure virtual functions
are defined.

The error message is saying that you've tried to create an object of
abstract class type "CPoleCache::CCacheViewImpl", perhaps by creating
the object on the heap with "new", or creating the object on the stack
with
CPoleCache::CCacheViewImpl foo;

If you're new to C++, you definitely need this:
http://www.parashift.com/c++-faq-lite/
 
G

Gavin Deane

Simon said:
A pure virtual function is a function which is declared in its class
with the suffix "=0".
Yes.

This means that the function is not defined in
its class.

Not necessarily. A pure virtual function can still have a definition.
Pure virtual implies that the definition *may* be omitted, not that the
definition *must* be omitted. And with a pure virtual destructor, you
will need to provide a definition (even if it is empty) or you will not
be able to link.

A class with one or more pure virtual functions is abstract. It does
not matter whether some or all of those functions have definitions.

Gavin Deane
 
S

Simon Elliott

Not necessarily. A pure virtual function can still have a definition.
Pure virtual implies that the definition may be omitted, not that the
definition must be omitted. And with a pure virtual destructor, you
will need to provide a definition (even if it is empty) or you will
not be able to link.

Yes. I didn't mention this because I wanted to keep things simple for
the OP. Herb Sutter's classic description of this here:

http://www.gotw.ca/gotw/031.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top