Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Combining Structs and Enums | Enumerations in C++
C++ Structures and Enumerations

bookChallenge: Combining Structs and Enums

Opgave

Swipe to start coding

Define a struct named Student that contains an enum Level with the values Freshman, Sophomore, Junior, Senior and a member variable level of type Level. Write a function named isSenior that takes a Student object as a parameter and returns true if the student's level is Senior, otherwise returns false. In the main function, create a Student with the level set to Senior and another with the level set to Junior. Print the result of calling isSenior for both students using the format: "Is the student a senior? {result}", where {result} is true or false.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

Awesome!

Completion rate improved to 8.33

bookChallenge: Combining Structs and Enums

Stryg for at vise menuen

Opgave

Swipe to start coding

Define a struct named Student that contains an enum Level with the values Freshman, Sophomore, Junior, Senior and a member variable level of type Level. Write a function named isSenior that takes a Student object as a parameter and returns true if the student's level is Senior, otherwise returns false. In the main function, create a Student with the level set to Senior and another with the level set to Junior. Print the result of calling isSenior for both students using the format: "Is the student a senior? {result}", where {result} is true or false.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

some-alt