Тэги:
#C++_Tutorial #Professor_Hank_Stalica #C++_Tutorial_Multiple_Inheritance #cpp #visual_studio #c++_classes #classes #programming #object_oriented_programming #inheritance #cpp_tutorials #c++_tutorial_for_beginners #program_examples #oop #learn_to_program #Professor_Hank #multiple_inheritance #inheritence #learn_c++ #c++_lecture #lecture #c++_programming #c++_inheritance #c++_multiple_inheritanceКомментарии:
Thanks!
You have left some int in the float class though)
Thanks, that helped.
ОтветитьThis tutorial rules. I was having trouble with my homework and this helped me so much because I was having issues with ambiguity.
ОтветитьNow I figure out why previous post don't work.
struct GAME : public MAP, public PIKA {
void t(char c){
PIKA::turning_side = c;
}
void test() {
PIKA::testi();
}
};
void main(){
GAME game;
game.t('L');
}
Turns out that Creating new parent GAME creates also new child PIKA, and this is separate from main loop. It means that I can't use separately in main PIKA, full it with data and then use in GAME, but I need initiate GAME, and from GAME level initiate all values of PIKA.
I try use it, but I have error.
struct PIKA{
int x;
int y;
char turning_side;
pair <int, int> pos;
void update_pos(int _x, int _y){
x = _x;
y = _y;
}
void update_pos(pair<int,int> _pos){
x = _pos.first;
y = _pos.second;
}
void update_side(char _c){
turning_side = _c; // this line get char ' L '
}
void testi(){
cerr << turning_side << endl;
}
};
struct GAME : public PIKA {
void test() {
PIKA::testi(); // This line cant display char ' L ' but displays ' ` ' an error.
}
};
And rather get character ' L ' I get ' ` ' Its like Parent class GAME using that function from child, that child don't have that character, but when I call that funcion from PIKA, value is corect. I do something wrong?