728x90 dart 객체지향 프로그래밍2 Dart 객체지향 프로그래밍 - 상속(Inheritance) 상속(Inheritance)상속은 부모 클래스의 속성과 메서드를 자식 클래스에서 사용할 수 있도록 하는 기능입니다.1. 기본 상속class Animal { String name; Animal(this.name); void makeSound() { print("$name이(가) 소리를 냅니다."); }}class Dog extends Animal { Dog(String name) : super(name); void bark() { print("$name이(가) 짖습니다. 🐶"); }}void main() { Dog dog = Dog("멍멍이"); dog.makeSound(); // 멍멍이가 소리를 냅니다. dog.bark(); // 멍멍이가 짖습니다. 🐶}super.. 2025. 2. 24. Dart 객체지향 프로그래밍 - 클래스와 객체 Dart 객체지향 프로그래밍 (OOP) - Class와 ObjectDart는 객체지향 프로그래밍(OOP: Object-Oriented Programming)을 지원하는 언어입니다.OOP의 핵심 개념인 클래스(Class), 객체(Object), 생성자(Constructor), 상속(Inheritance), 다형성(Polymorphism), 캡슐화(Encapsulation), 추상 클래스(Abstract Class), 인터페이스(Interface), 믹스인(Mixin) 등을 지원합니다.1. 클래스(Class)와 객체(Object)Dart에서 클래스는 객체를 생성하는 틀(템플릿) 역할을 하며, 객체는 클래스의 인스턴스(Instance) 입니다.1. 1 클래스 정의 및 객체 생성class Person { St.. 2025. 2. 24. 이전 1 다음 728x90