User forums > Help
Class Inheritance bug?
Amsterdam:
Code::Blocks refuses to recognize class inheritance altogether. Despite the code being simplistic.
Even if I try something banal, such as
class parent {
public:
int forinheritance
};
class child : public parent {
};
Code::Blocks still shows and treats "child" as being memberless.
I just installed Code::Blocks with as part of the standard package, never changed a thing.
Anyone have a clue whats wrong?
oBFusCATed:
Please post the exact steps to reproduce the problem?
Where is the cursor when you've hit the control-space to show the auto complete (if the problem is in auto complete, because it is not obvious)?
What version of cb are you using?
Amsterdam:
Code::Blocks 16.01 it is.
How can auto complete be the issue? Could you elaborate? The auto complete does indeed recognize classes correctly.
I thought the exact code is redundant, but here it is. Trying to give "Ally" a "cardname" throws an error during compilation: cardname not declared in this scope.
--- Code: ---#ifndef CARD_H
#define CARD_H
#include <string>
using namespace std;
class Card
{
public:
Card();
virtual ~Card();
protected:
int cardnumber;
string cardname;
private:
};
#endif // CARD_H
#ifndef ALLY_H
#define ALLY_H
#include <string>
#include <vector>
class Ally : public Card
{
public:
Ally(int mycardnumber, string mycardname, int mypower, int mystage, string mycategory);
virtual ~Ally();
protected:
int power;
int stage;
vector<string> category;
private:
};
#endif // ALLY_H
--- End code ---
oBFusCATed:
--- Quote from: Amsterdam on September 21, 2016, 07:55:58 pm ---How can auto complete be the issue? Could you elaborate? The auto complete does indeed recognize classes correctly.
--- End quote ---
Because this is the only thing C::B could be blamed on.
And because this is what I've guessed from your vague post.
--- Quote from: Amsterdam on September 21, 2016, 07:55:58 pm ---I thought the exact code is redundant, but here it is. Trying to give "Ally" a "cardname" throws an error during compilation: cardname not declared in this scope.
--- End quote ---
Sorry but compilation problems are not related to codeblocks, thus they aren't discussed on the codeblocks forums. Check the rules again if you don't believe me. And codeblocks is not a compiler, but an IDE. There is a serious difference between the two kinds of application types. If you understand the difference there is bigger chance to understand and fix your problem.
p.s. And please next time use code tag to wrap code you're pasting here. They make post a bit more tidy.
Amsterdam:
So I disabled the auto correct and typed the class names anew, but it did not solve the inheritance problems.
I still do believe the problem to be Codeblocks related, as inheritance worked perfectly fine in other IDEs, utilizing the same code.
p.s. Done.
Navigation
[0] Message Index
[#] Next page
Go to full version