類Brass和繼承類BrassPlus都有ViewAcct()函數(shù)
BrassPlus ophelia;
Brass * bp;
bp = &ophelia;
bp->ViewAcct(); //調(diào)用哪個(gè)類的函數(shù),取決于是不是虛函數(shù)
- 不是虛的按聲明的指針Brass *,虛的按指向的對(duì)象&ophelia(即BrassPlus)
類Brass和繼承類BrassPlus都有ViewAcct()函數(shù)
BrassPlus ophelia;
Brass * bp;
bp = &ophelia;
bp->ViewAcct(); //調(diào)用哪個(gè)類的函數(shù),取決于是不是虛函數(shù)