Returning structures from functions -- C++ Structs Tutorial #7

Поділитися
Вставка
  • Опубліковано 18 лис 2024

КОМЕНТАРІ • 8

  • @__hannibaal__
    @__hannibaal__ Рік тому

    This why love C/C++ ; you can return every thing by function. And get every thing.

  • @pedr9vskcray2102
    @pedr9vskcray2102 Рік тому

    thank you, amazing teaching!

  • @Amdebirhan_Abebe
    @Amdebirhan_Abebe Рік тому

    Thank you, That was amazing . Keep up the hardwork !

  • @Chalisque
    @Chalisque Рік тому

    I'm not sure whether it gets optimises away in your case, but
    Circle p
    p = getCircle()
    results in one more construction of a circle than
    Circle p = getCircle()
    That is, the line
    Circle p
    causes a Circle to be constructed and assigned to p, then
    p = getCircle()
    causes another Circle to be constructed inside getCircle() and this is then assigned to p.

    • @ProfessorHankStalica
      @ProfessorHankStalica  Рік тому

      That makes sense since there is a local Circle variable created in getCircle. So, you should have two constructed, the Circle in getCircle and the Circle in main.

  • @faizaniftikhar
    @faizaniftikhar 10 місяців тому

    interestingly we can initialize like this too
    struct Test {
    int i;
    float f;
    char c;
    };
    Test initialize() {
    return { 0,1.02,' ' };
    }

  • @__hannibaal__
    @__hannibaal__ Рік тому

    Thumb ⬆️