Object-oriented programs typically consist of many objects bound together to form a complete program. The binding allows the objects to communicate, and by communicating, they cooperate to solve the problem for which we wrote the program. Chapter 10 demonstrates how to build programs consisting of multiple objects instantiated from multiple classes.
Please focus on the following as you study chapter 10:
Inheritance | Composition | Aggregation | Dependency | |
---|---|---|---|---|
class Foo
{
...
};
|
class Bar : public Foo
{
...
};
|
class Bar
{
private:
Foo f;
}; |
class Bar
{
private:
Foo* f;
}; |
class Bar
{
public:
void function(Foo f) {...}
}; |
Association | |
---|---|
class Foo; // forward declaration (pointer only)
class Bar
{
private:
Foo* f;
}; |
class Bar; // forward declaration (pointer only)
class Foo
{
private:
Bar* b;
}; |