接着我们采用 ODB 的案例利用odb 编译器生成相应的代码吧
#ifndef PERSON_HXX#define PERSON_HXX#include#include //std::size_t
#include
#pragma db object
classperson
{public:
person (const std::string&first,const std::string&last,
unsignedshortage)
: first_ (first), last_ (last), age_ (age)
{
}const std::string&first ()const{returnfirst_;
}const std::string&last ()const{returnlast_;
}
unsignedshortage ()const{returnage_;
}voidage (unsignedshortage)
{
age_=age;
}private:
friendclassodb::access;
person () {}#pragma db id autounsignedlongid_;
std::stringfirst_;
std::stringlast_;
unsignedshortage_;
};#pragma db view object(person)
structperson_stat
{#pragma db column("count(" + person::id_ + ")")std::si