c++ - Pointers to virtual classes -


recently, stumbled on c++ problem gives me quite hard time. suppose have small program:

class {   public:     virtual bool c() = 0;     virtual bool b() = { return false; };     virtual ~a() {} }  class b : public {    public:      bool b() = { return true; };      ~b() {} }  ...  void c(a *pointer) {   if (pointer->b()) {     cout << "derived class";   } } 

in case, compiler returns error on "if" line of method c() error "member access incomplete type a". can explain me why compiler returning such error? , if indeed right in firing exception, how can prevent it?

thanks much!

"incomplete type a" means in code you're compiling (but not code posted), there isn't definition of a before it's used in c. need definition either in same source file c, or in header included source file.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -