#include <iostream>
typedef struct Person{
int value;
}Person;
int main(){
Person p1 = {1};
Person p2 = {2};
Person p3 = {3};
Person p4 = {4};
int a = 2;
int b = 2;
Person * ptrPerson[a][b];
ptrPerson[0][0] = &p1;
ptrPerson[0][1] = &p2;
ptrPerson[1][0] = &p3;
ptrPerson[1][1] = &p4;
std::cout << ptrPerson[0][0]->value <<std::endl; //결과 : 1
std::cout << ptrPerson[0][1]->value <<std::endl; //결과 : 2
std::cout << ptrPerson[1][0]->value <<std::endl; //결과 : 3
std::cout << ptrPerson[1][1]->value <<std::endl; //결과 : 4
}
C++ 개념 더보기
'◼️C++' 카테고리의 다른 글
[C++] 벡터 구조체 정렬. 오름차순, 내림차순, 같을 경우 다른 요소 기준으로 순서 지정 (0) | 2023.10.20 |
---|---|
[C++] 구조체를 함수로 넘겨서 값 변경하기 (0) | 2023.10.19 |
[C++] 클래스의 정적멤버 (static) (0) | 2023.09.17 |
[C++] delete 예약어를 이용한 명시적 메서드 삭제 (0) | 2023.09.17 |
[C++] 상수형 메서드, mutable, const_cast< > (0) | 2023.09.17 |