Ejemplo n.º 1
0
int main(){
Lemon lemon(2.0);
//This is perfectly legal!
CitrusFruit &rlemon = lemon;
CitrusFruit *plemon = &lemon;
cout << "lemon is a " << lemon.getName()
<< " and has a pH " << lemon.getPh() << endl;
cout << "rlemon is a " << rlemon.getName()
<< " and has a pH " << rlemon.getPh() << endl;
cout << "plemon is a " << plemon->getName()
<< " and has a pH " << plemon->getPh() << endl;
}
Ejemplo n.º 2
0
 void PrintTheFruits(CitrusFruit &fruit){
	 std::cout << "fruit is a " << fruit.getName()
	      << " and has a pH " << fruit.getPh()
		  << std::endl;
 }