class Object
{
public:
getName();
}
class Input : public Object
{
//Whatever in here
}
Input i;
i.getName(); //Error
Inheritance question
Hi, I have a base class Object with name, id, a dispose method etc. But when I Inherit it I can't see any of those methods and it won't let me compile saying method doesn't exist.
I am using c++ vs2003 and directx. For example my Input class doesn't see the object methods. This is just some psuedocode. Is there any reason why something wouldn't be inherited?
I didn't want to post all my code because that would be alot to look through. It doesn't come up in Intellisense. I think it would come up there. The inheritance itself doesn't give a compiler error. All I wanted to know is there any reason why something wouldn't be inherited? Not just in my code but any code?
It could be declared private in the base class, or you could have not used public inheritence in the derived class.
Yah I checked that but all the methods I have in the base class are public, and in the child class i have it publicly inherit.
I think i have gotten closer to the error. I have namespaces, so will that cause an inheritance error.
Example
EDIT:: I can use the methods from the base class if it's in the same namespace, but if I inherit in a different namespace i can't. Is there something wrong in my code, or do I need to reference the namespace somehow I thought I was with the class Input : public BaseClass::Object.
Example
namespace BaseClass{ class Object { public: getName(); }}namespace InputClass{ class Input : public BaseClass::Object { //Whatever in here }}Input i;i.getName(); //Error
EDIT:: I can use the methods from the base class if it's in the same namespace, but if I inherit in a different namespace i can't. Is there something wrong in my code, or do I need to reference the namespace somehow I thought I was with the class Input : public BaseClass::Object.
Im out of ideas then, how can I see the methods if they are in the same namespace but if its not I can't see the methods. I'm getting ready to go to a different language.
Zip your code or post your class design. You only need the 2 classes.
The base and the inherited. Then show us the implementation.
Its ok to have a lot of code posted.
The base and the inherited. Then show us the implementation.
Its ok to have a lot of code posted.
this code works fine, and they are in different namespaces
#include <iostream>namespace One{ class Test{ public: int getOne(){ return 550; } }; }namespace Two{ class TestTwo : public One::Test{ }; } int main(){ Two::TestTwo obj; std::cout << obj.getOne() << std::endl; }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement