ML record โ‡’ C++ Struct

build struct and variable

struct {
	type1 f1;
	type2 f2;
} v1,v2...;

assign field

v1.f1= e1;
...
vn.fn = en;

access field

v1.f1
v1.fn
...

ex)

struct student {
	 string name;
	optional<int> id;
};
student james = {"james", 42};
auto students = {james};
**for(auto s: students)** {
	std::cout << s.name << std::endl;
}

๋งŒ์•ฝ์— ์ƒ์„ฑ์ž๊ฐ€ ์žˆ๋‹ค๋ฉด ๊ทธ ์ƒ์„ฑ์ž๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์—†๋‹ค๋ฉด list syntax๋ฅผ ์ด์šฉํ•ด์„œ c++ ์ปดํŒŒ์ผ๋Ÿฌ๋Š” first field๋ฅผ ์ฒซ๋ฒˆ์งธ์— ๋‘๋ฒˆ์งธ๋Š” ๋‘๋ฒˆ์งธ ๋ณ€์ˆ˜์— ๋„ฃ์Œ. ์ด ๋•Œ optional์ด๋ž‘ ์•ˆ๋งž๊ธฐ์— c++์€ ์•Œ์•„์„œ optional์— int๋ฅผ ๋ฐ›๋Š” ์ƒ์„ฑ์ž๊ฐ€ ์žˆ๋Š”์ง€ ์ฒดํฌ: optional int ์ƒ์„ฑ โ†’ stduent ๋ณ€์ˆ˜ ์ƒ์„ฑ

ML Data Bining โ‡’ C++ Variant