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

Scorri per mostrare il menu

book
Constructor Delegation Practice

Compito

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.

Soluzione

cpp

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 6

Chieda ad AI

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

book
Constructor Delegation Practice

Compito

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.

Soluzione

cpp

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 6
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt