Main Function

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

WateringPlan.C
#include <iostream.h>
#include <string.h>
#include "Plant.h"
#include "PlantList.h"

using namespace std;

int main() {
   PlantList plants;
   string name; int frequency;

   while (cin >> name && cin >> frequency) {
      plants.add(Plant(name, frequency));
   }
   plants.print_plan();
}

*While cin >> name normally returns cin to permit a concatenation of operations, it is in the given context

*implicitly converted to void * (an unspecified pointer) with the support of a conversion operator of cin,
 
*and subsequently implicitly converted to bool.
 

*This works in a way that the condition evaluates to true if both read operations succeed and to false otherwise.
 
*Plant(name, frequency) creates an anonymous object of type Plant that is destroyed after the execution of the statement using it finishes.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 21, 2002