Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Pure Virtual functions in CDT(Pure Virtual Functions C++ GCC 4.5.2)
Pure Virtual functions in CDT [message #734578] Sat, 08 October 2011 18:17 Go to next message
Josiah  is currently offline Josiah Friend
Messages: 7
Registered: October 2011
Junior Member
I'm getting another strange problem.

Say I have:
virtual class IHelper {
     virtual int Method() = 0;
};

virtual class IMainClass {
    virtual IHelper OtherMethod() = 0;
};


Why does this give me the error message:
The type 'IHelper' must implement the inherited pure virtual method 'IHelper::Method'


I tried adding this class, but the error didn't change:
virtual class Helper : IHelper {
    virtual int Method() {
        return 0;
    }
};


Interestingly, if I remove the "= 0" from the method declaration so that the method is not declared as pure virtual, the error message goes away.

I'm using GCC 4.5.2 in Ubuntu 11.04

Re: Pure Virtual functions in CDT [message #734617 is a reply to message #734578] Sat, 08 October 2011 22:35 Go to previous message
Josiah  is currently offline Josiah Friend
Messages: 7
Registered: October 2011
Junior Member
I feel dumb. All I had to do was declare the return type of OtherMethod as a reference/pointer instead of an instance (duh, it's an interface).
e.g.
class IMainClass {
    virtual IHelper* OtherMethod() = 0;
};
Previous Topic:Accessing external library from C project
Next Topic:No output when running C++ applications via Eclipse CDT IDE
Goto Forum:
  


Current Time: Thu Apr 25 06:47:09 GMT 2024

Powered by FUDForum. Page generated in 0.02677 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top