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

Зміст курсу

C++ OOP

C++ OOP

1. Fundamentals of OOP
2. Constructors and Destructors
3. Encapsulation Overview
4. Inheritance Overview
5. Polymorphism Overview

bookAttributes of the Class

Class is like a container for two primary elements: attributes and methods. In this chapter we will learn about attributes and how to use them. For a student class common attributes will be name, gpa, email etc.

Understanding Attributes

Attributes, also often referred as properties or fields, they are the variables that are held within a class. Their job is to represent the state or qualities of objects created from the class.

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

cpp

main

copy
12345678910
class Example { public: float attribute; }; int main() { Example obj; obj.attribute = 25; }

Note

Don't be bothered about public keyword. It will be explained later.

Завдання

  • Add two more attributes to a student class.
  • Create an object of the class.
  • Assigned values to the attributes of created instance.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
toggle bottom row

bookAttributes of the Class

Class is like a container for two primary elements: attributes and methods. In this chapter we will learn about attributes and how to use them. For a student class common attributes will be name, gpa, email etc.

Understanding Attributes

Attributes, also often referred as properties or fields, they are the variables that are held within a class. Their job is to represent the state or qualities of objects created from the class.

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

cpp

main

copy
12345678910
class Example { public: float attribute; }; int main() { Example obj; obj.attribute = 25; }

Note

Don't be bothered about public keyword. It will be explained later.

Завдання

  • Add two more attributes to a student class.
  • Create an object of the class.
  • Assigned values to the attributes of created instance.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
toggle bottom row

bookAttributes of the Class

Class is like a container for two primary elements: attributes and methods. In this chapter we will learn about attributes and how to use them. For a student class common attributes will be name, gpa, email etc.

Understanding Attributes

Attributes, also often referred as properties or fields, they are the variables that are held within a class. Their job is to represent the state or qualities of objects created from the class.

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

cpp

main

copy
12345678910
class Example { public: float attribute; }; int main() { Example obj; obj.attribute = 25; }

Note

Don't be bothered about public keyword. It will be explained later.

Завдання

  • Add two more attributes to a student class.
  • Create an object of the class.
  • Assigned values to the attributes of created instance.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Class is like a container for two primary elements: attributes and methods. In this chapter we will learn about attributes and how to use them. For a student class common attributes will be name, gpa, email etc.

Understanding Attributes

Attributes, also often referred as properties or fields, they are the variables that are held within a class. Their job is to represent the state or qualities of objects created from the class.

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

cpp

main

copy
12345678910
class Example { public: float attribute; }; int main() { Example obj; obj.attribute = 25; }

Note

Don't be bothered about public keyword. It will be explained later.

Завдання

  • Add two more attributes to a student class.
  • Create an object of the class.
  • Assigned values to the attributes of created instance.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 4
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt