C++ · ОСНОВЫ · LESSON 19
Item with properties
struct · about 12 minutes
Learning with progressRead the summary for free. To save the work, log in to the account.
Type the code yourself
Manually type the program from the sample. So you'll remember commands and brackets.
#include <iostream>
#include <string>
using namespace std;
struct Pet {
string name;
int age;
};
int main() {
Pet dog = {"Бим", 3};
cout << dog.name << endl;
return 0;
}Open the editor for class workSolve it yourself
Create struct Pet with string name and int age properties. Create pet with the name «Кот» and age 4; output pet.age.
The answer is hidden. Use similar examples from the lesson notes.
Opening up your homework