Employee* boss = new Employee("Lin, Lisa", 68000);delete
delete(boss);
the uses of pointer
1.optional attribute
class Department
{
. . .
private:
string name;
Employee* receptionist;};
is better than class Department // modeled without pointer
{
. . .
private:
string name;
bool has_receptionist;
Employee receptionist;
};2.sharing
没有评论:
发表评论