내 프로그램은 C++로 작성되었습니다.std :: map <string, class> 키 값을 인쇄하십시오.
#include <iostream>
#include <string>
#include <map>
using namespace std;
class Details
{
int x;
int y;
};
typedef std::map<string, Details> Det;
Det det;
Details::Details(int p, int c) {
x = p;
y = c;
}
int main(){
det.clear();
insertNew("test", 1, 2);
cout << det["test"] << endl;
return 0;
}
가장 간단한 방법으로 키 값을 인쇄하고 싶습니다. 예 : det [ "test"] 컴파일이 실패합니다. "test"키에 해당하는 (x, y) 값을 인쇄하는 방법은 무엇입니까?
위의 코드는 구문 오류가 많으며 유효한 프로그램이 아닙니다. 컴파일 할 수없는 실제 코드를 입력하십시오. – ybungalobill
코드 끝에 두 개의 닫는 괄호가 없습니다. – LowTechGeek
@ybungalobill, 우리가 옳습니다. 내 코드를 실제 코드로 업데이트합니다. – cateof