ÀνºÅϽº (Instance)
ÀνºÅϽº (Instance)
- ÀνºÅϽº
- An instance is an object which belongs to a class.
- All instances of a class have the same set of attributes and methods.
- ½ÇÁ¦ ±¸Çö ¹æ¹ý
- Each instance has a well-defined set of methods.
- But, the methods are not stored in each object.
- Methods are stored only once and all objects of a given class share it.
- The method is part of the class, not part of object.
Notes:
- Instantiation in C++
- int main( ) {
Employee Bob, John;
Bob.promote(director);
Employee* E1;
E1 = &Bob;
E1->promote(president):
...
}