1) Why would you use composition?
2) How do you use composition?
2 personal knowhow :
class poultry{
Chicken first;
Egg second;
Chick third;
...
};
Something like that, I know the classes and names are not quite that composition is, but the overall idea is.
3) how do you use the classes within the class? is it something like:
void first::weight()
{
int weight;
cout << "get weight: ";
cin >> weight;
cout << "You entered " << weight << " for the chicken" << endl;
}
int main()
{
Poultry frozen;
first.weight();
...}
???
Would you just use the classes as normal within main()?
[/code]

New Topic/Question
Reply



MultiQuote





|