constructor

C++์—์„œ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ, ๋Œ€์ž… ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๋ฆฌ์ŠคํŠธ์˜ ํ˜•์‹์œผ๋กœ ์ดˆ๊ธฐํ™” ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์šฐ๋ฆฌ๋Š” ์ƒ์„ฑ์ž ์ดˆ๊ธฐํ™” ๋ฆฌ์ŠคํŠธ ๋ผ๊ณ  ๋ถ€๋ฆ…๋‹ˆ๋‹ค ์˜ˆ์‹œ๋ฅผ ๋ณด์—ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. class Player { private: string name{}; int health{}; int xp{}; public: // Constructor Player(string name_val, int health_val, int xp_val); }; Player::Player(string name_val, int health_val, int xp_val) : name{name_val}, health{health_val}, xp{xp_val} {} ํ•˜์ง€๋งŒ ์ž…๋ ฅํ•˜๋Š” ์‚ฌ๋žŒ์ด ๋ชจ๋“  ๊ฐ’์„ ์ž…๋ ฅํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์šฐ๋ฆฌ๋Š” ์˜ค๋ฒ„..
Chan Lee
'constructor' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก