Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Attributes of the Class | Fundamentals of OOP in C++
C++ OOP

Deslize para mostrar o menu

book
Attributes of the Class

h

syntax

copy
1234
class Name { public: Type AttributeName; };

Public attributes and methods in a class can be directly accessed using the dot operator (.) on an object of the class.

cpp

main

copy
12345678910111213
class Student { public: int age; }; int main() { Student bob; Student ann; bob.age = 25; ann.age = 33; }
Tarefa

Swipe to start coding

You are working with a Student class and need to enhance its structure and usage.

  • Add two additional attributes to the Student class: name (string) and gpa (float).
  • Create an object of the Student class.
  • Assign appropriate values to the attributes name, gpa, and email of the created instance.

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 1. Capítulo 4

Pergunte à IA

expand
ChatGPT

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

book
Attributes of the Class

h

syntax

copy
1234
class Name { public: Type AttributeName; };

Public attributes and methods in a class can be directly accessed using the dot operator (.) on an object of the class.

cpp

main

copy
12345678910111213
class Student { public: int age; }; int main() { Student bob; Student ann; bob.age = 25; ann.age = 33; }
Tarefa

Swipe to start coding

You are working with a Student class and need to enhance its structure and usage.

  • Add two additional attributes to the Student class: name (string) and gpa (float).
  • Create an object of the Student class.
  • Assign appropriate values to the attributes name, gpa, and email of the created instance.

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 1. Capítulo 4
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