Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Constructor Delegation Practice | Constructors and Destructors
C++ OOP

Deslize para mostrar o menu

book
Constructor Delegation Practice

Tarefa

Swipe to start coding

You're working with a class that has multiple constructors. During code review, you were asked to refactor them using initialization lists for better performance and cleaner code.

  • The default constructor should delegate to the main constructor, passing default values.
  • The constructor that sets only the name should also delegate, using defaults for the other fields.
  • The one that sets name and age should delegate too, passing a default salary.
  • The fully parameterized constructor stays as is.

Solução

cpp

solution

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 6

Pergunte à IA

expand
ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

book
Constructor Delegation Practice

Tarefa

Swipe to start coding

You're working with a class that has multiple constructors. During code review, you were asked to refactor them using initialization lists for better performance and cleaner code.

  • The default constructor should delegate to the main constructor, passing default values.
  • The constructor that sets only the name should also delegate, using defaults for the other fields.
  • The one that sets name and age should delegate too, passing a default salary.
  • The fully parameterized constructor stays as is.

Solução

cpp

solution

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 6
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt