https://www.learncpp.com/cpp-tutorial/introduction-to-structs-members-and-member-selection/
struct 또한 program-defined type이다
아래와 같이 define한다
struct Employee
{
int id {};
int age {};
double wage {};
};
struct type을 정의한다고 object가 만들어지는 것은 아니다
object는 다음과 같이 방법으로 만든다
Employee joe; // Employee is the type, joe is the variable name
joe의 member variable에 접근하기 위해서 member selection operator ( . )을 사용한다
#include <iostream>
struct Employee
{
int id {};
int age {};
double wage {};
};
int main()
{
Employee joe;
joe.age = 32; // use member selection operator (.) to select the age member of variable joe
std::cout << joe.age; // print joe's age
return 0;
}