Загрузка...

Structures in C++|| C++ Complete Course || Beginners to Advance| Urdu/Hindi | BJM Technologies

C++ Structures
Structures (also called structs) are a way to group several related variables into one place. Each variable in the structure is known as a member of the structure.

Unlike an array, a structure can contain many different data types (int, string, bool, etc.).

Create a Structure
To create a structure, use the struct keyword and declare each of its members inside curly braces.

After the declaration, specify the name of the structure variable (myStructure in the example below):

struct { // Structure declaration
int myNum; // Member (int variable)
string myString; // Member (string variable)
} myStructure; // Structure variable
Access Structure Members
To access members of a structure, use the dot syntax (.):

Example
Assign data to members of a structure and print it:

// Create a structure variable called myStructure
struct {
int myNum;
string myString;
} myStructure;

// Assign values to members of myStructure
myStructure.myNum = 1;
myStructure.myString = "Hello World!";

Видео Structures in C++|| C++ Complete Course || Beginners to Advance| Urdu/Hindi | BJM Technologies канала BJM Technologies
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять