#include<unordered_map>
#include<iostream>
using namespace std;
class A{
private:
int x;
int y;
float x_f;
float y_f;
public:
A(int _x,int _y,float f_x,float f_y):x(_x),y(_y),x_f(f_x),y_f(f_y){}
void getCurrrentValue(){
cout<<x<<","<<y<<"/"<<x_f<<","<<y_f<<"\n";
}
};
int main(void){
unordered_map<int,A> my_map;
my_map.insert({1,A(1,2,1.1,1.2)});
my_map.insert({2,A(3,4,1.2,1.3)});
for (auto& element : my_map){
element.second.getCurrrentValue();
}
return 0;
}
Created
October 2, 2021 13:53
-
-
Save jeon3029/3ed5f3c3d5aba68597617d6ec11969c5 to your computer and use it in GitHub Desktop.
c++ / unordered map with class Example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment