VVContactRepository Constructor
Let’s look closely at the constructor for VVContactRepository found in the file conrep.cpp. This constructor sets the stage for manipulating the pool of customers.
 
VVContactRepository::VVContactRepository
(const RWDBDatabase& theDB,
const RWCString& theTableName) //1
: aDB_(theDB) //2
, table_(aDB_.table(theTableName)) //3
, nameColumn_(table_["name"]) //4
, idColumn_(table_["ID"])
, addressColumn_(table_["address"])
, cityColumn_(table_["city"])
, stateColumn_(table_["state"])
, zipColumn_(table_["zip"])
, phoneColumn_(table_["phone"])
{
; //5
}
//1 The first line simply declares the input parameters: a reference to the database and the name of the table holding the customer data.
//2 An instance of VVContactRepository maintains a copy of the database that it is associated with. This initialization makes the association.
//3 An instance of VVContactRepository also maintains a table that represents the customer table in the database. It does this by calling the table() member function of its database object. This function returns an instance of RWDBTable. It is important to note that creating an instance of RWDBTable does not force the RWDBDatabase instance to check the server for the existence of the table. The DB Interface Module accesses the database server only when data is actually manipulated or read. When the table() member function of the class RWDBDatabase instance returns an RWDBTable instance, it is saved by this constructor for future use.
//4 In these seven lines, the columns of the table in the database are identified and saved as instances of RWDBColumn. Most of these columns are not used in this tutorial, but they are important in future exercises.
//5 The actual body of the constructor has nothing to do. All the work was done by the initializations.