42seoul/projects

[C++] ์„œ๋ธŒ ํƒ€์ž… ๋‹คํ˜•์„ฑ(Subtype Polymorphism)

moaoh 2023. 9. 13. 05:10

์˜ค๋ฒ„๋กœ๋”ฉ์ด๋‚˜ ๋Ÿฐํƒ€์ž„ ๋‹คํ˜•์„ฑ์œผ๋กœ๋„ ๋ถˆ๋ฆฐ๋‹ค.

class Animal {
	// ...
};

class Cat : public Animal {
	// ...
};

int main(void) {

		const Animal* temp = new Cat();
    
    return 0;
}

์ƒ์†๋ฐ›์€ ์ƒ์œ„ ํด๋ž˜์Šค์˜ ๋งค์†Œ๋“œ๋ฅผ ์žฌ์ •์˜ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์„ ์„œ๋ธŒํƒ€์ž… ๋‹คํ˜•์„ฑ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค๊ณ ํ•œ๋‹ค.


https://github.com/utilForever/modern-cpp-tutorial/blob/master/Articles/The%20Four%20Polymorphisms%20in%20C%2B%2B.md

 

๋Œ“๊ธ€์ˆ˜0