C++ Tutorial: Multiple Inheritance // Giving your classes multiple parents

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 9

  • @gabic8320
    @gabic8320 3 года назад +2

    This tutorial rules. I was having trouble with my homework and this helped me so much because I was having issues with ambiguity.

    • @ProfessorHankStalica
      @ProfessorHankStalica  3 года назад

      Thanks for the kind words! I'm glad you were able to get some use out of it!

  • @maxim25o2
    @maxim25o2 4 года назад +1

    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.

  • @anton_98
    @anton_98 2 года назад +1

    Thanks!
    You have left some int in the float class though)

  • @watcher8582
    @watcher8582 3 года назад +2

    Thanks, that helped.

  • @maxim25o2
    @maxim25o2 4 года назад

    I try use it, but I have error.
    struct PIKA{
    int x;
    int y;
    char turning_side;
    pair pos;
    void update_pos(int _x, int _y){
    x = _x;
    y = _y;
    }
    void update_pos(pair _pos){
    x = _pos.first;
    y = _pos.second;
    }
    void update_side(char _c){
    turning_side = _c; // this line get char ' L '
    }
    void testi(){
    cerr