本文整理汇总了C++中CDatabase::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatabase::Add方法的具体用法?C++ CDatabase::Add怎么用?C++ CDatabase::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatabase
的用法示例。
在下文中一共展示了CDatabase::Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
CCar::clone_into (CDatabase &db) const
{
for (int i = 0; i < m_LogNr; i++)
{
const TLog &log = m_Log[i];
db.Add (log.m_Date,
log.m_Driver->m_Name, log.m_Driver->m_Surname, m_RZ);
}
}
示例2: name
int
main (int argc, char *argv[])
{
CDatabase *a, *b, *c;
a = new CDatabase;
assert (a->Add ("2012-03-01", "John", "Nowak", "ABC-12-34"));
assert (a->Add ("2012-03-02", "John", "Nowak", "ABC-12-34"));
assert (a->Add ("2012-03-03", "John", "Nowak", "DEF-56-67"));
assert (a->Add ("2012-03-02", "George", "Smith", "DEF-56-67"));
cout << *a;
cout << a->FindCar ("ABC-12-34");
cout << a->FindDriver ("John", "Nowak");
try {
cout << a->FindCar ("XYZ-99-88");
abort ();
} catch (const InvalidCarException &e) {
ostringstream ss;
ss << e;
assert (ss.str () == "XYZ-99-88");
}
try {
cout << a->FindDriver ("John", "Smith");
abort ();
} catch (const InvalidDriverException &e) {
ostringstream ss;
ss << e;
assert (ss.str () == "John Smith");
}
delete a;
a = new CDatabase;
assert (a->Add ("2012-03-01", "John", "Nowak", "ABC-12-34"));
assert (a->Add ("2012-03-02", "George", "Smith", "DEF-56-67"));
cout << *a;
assert (!a->Add ("2012-03-01", "John", "Nowak", "XYZ-99-99"));
assert (!a->Add ("2012-03-02", "Peter", "McDonald", "DEF-56-67"));
cout << *a;
delete a;
a = new CDatabase;
b = new CDatabase;
assert (a->Add ("2012-03-01", "John", "Nowak", "ABC-12-34"));
assert (a->Add ("2012-03-02", "John", "Nowak", "DEF-56-67"));
assert (a->Add ("2012-03-01", "George", "Smith", "DEF-56-67"));
assert (a->Add ("2012-03-02", "George", "Smith", "ABC-12-34"));
cout << *a;
*b = *a;
c = new CDatabase (*a);
assert (b->Add ("2012-03-03", "Homer", "Simpson", "ABC-12-34"));
assert (c->Add ("2012-03-03", "Homer", "Simpson", "DEF-56-67"));
delete a;
cout << *b;
cout << *c;
delete b;
delete c;
CDatabase *db;
db = new CDatabase;
const char *names[] = {"A", "B", "C", "D", "E", "F"};
char buf[40];
srand (8);
for (int i = 1000; i < 2000; i++)
{
string rz = "ABC-";
sprintf (buf, "%d", rand () % 100);
rz += buf;
string name (names[rand () % 6]);
string surname (names[rand () % 6]);
string date = "2012-";
sprintf (buf, "%d", i);
date += buf;
db->Add (date, name, surname, rz);
}
ostringstream outa, outb;
outa << *db;
outb << CDatabase (*db);
assert (outa.str () == outb.str ());
delete db;
return 0;
}