本文整理汇总了C++中Course::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Course::GetId方法的具体用法?C++ Course::GetId怎么用?C++ Course::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::GetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 课程类拷贝构造函数
Course::Course(const Course& course){
id = course.GetId();
name = course.GetName();
}
示例2: PQconnectdb
void Configuration::ReadDatabase() {
_professors.clear();
_studentGroups.clear();
_courses.clear();
_rooms.clear();
_courseClasses.clear();
mapid.clear();
PGconn *conn;
PGresult *res, *resgr;
int rec_count, rec_countgr;
int row,row1,col;
conn = PQconnectdb("dbname=gaschedule_development host=localhost user=alex password=alex");
if (PQstatus(conn) == CONNECTION_BAD)
{ puts("We were unable to connect to the database");}
res = PQexec(conn,"select * from rooms order by id");
if (PQresultStatus(res) != PGRES_TUPLES_OK) {puts("We did not get any data!");}
rec_count = PQntuples(res);
for (row=0; row<rec_count; row++) {
int id = atoi(PQgetvalue(res, row , 0));
char* name = PQgetvalue(res, row , 1) ;
bool lab = !strcmp ( PQgetvalue(res, row , 2), "t" );
int size = atoi(PQgetvalue(res, row , 3));
Room* r = new Room(name, lab, size );
int a = row;
a = a + 1;
mapid.insert(pair <int,int> (a,id));
if( r ) {
_rooms.insert( pair<int, Room*>( r->GetId(), r ) );
}
}
PQclear(res);
res = PQexec(conn, "select * from courses order by id");
if (PQresultStatus(res) != PGRES_TUPLES_OK) { puts("We did not get any data!");}
rec_count = PQntuples(res);
for (row=0; row<rec_count; row++) {
int id = atoi(PQgetvalue(res, row , 0));
char* name = PQgetvalue(res, row , 1) ;
Course* r = new Course(id, name );
if( r )
_courses.insert( pair<int, Course*>( r->GetId(), r ) );
}
PQclear(res);
res = PQexec(conn,"select * from professors order by id");
if (PQresultStatus(res) != PGRES_TUPLES_OK) { puts("We did not get any data!");}
rec_count = PQntuples(res);
for (row=0; row<rec_count; row++) {
int id = atoi(PQgetvalue(res, row , 0));
char* name = PQgetvalue(res, row , 1) ;
Professor* r = new Professor(id, name );
if( r )
_professors.insert( pair<int, Professor*>( r->GetId(), r ) );
}
PQclear(res);
res = PQexec(conn,"select * from groups order by id");
if (PQresultStatus(res) != PGRES_TUPLES_OK) { puts("We did not get any data!");}
rec_count = PQntuples(res);
for (row=0; row<rec_count; row++) {
int id = atoi(PQgetvalue(res, row , 0));
char* name = PQgetvalue(res, row , 1) ;
int size = atoi(PQgetvalue(res, row , 2));
StudentsGroup* r = new StudentsGroup(id, name , size );
if( r ) {
_studentGroups.insert( pair<int, StudentsGroup*>( r->GetId(), r ) );
}
}
PQclear(res);
list<StudentsGroup*> groups;
res = PQexec(conn, "select * from clas order by id");
if (PQresultStatus(res) != PGRES_TUPLES_OK) {puts("We did not get any data!");}
rec_count = PQntuples(res);
resgr = PQexec(conn,
"select clas.id, cla_groups.group_id from cla_groups INNER JOIN clas ON cla_groups.cla_id = clas.id");
if (PQresultStatus(resgr) != PGRES_TUPLES_OK) {puts("We did not get any data!"); }
rec_countgr = PQntuples(resgr);
for (row=0; row<rec_count; row++) {
int claid = atoi(PQgetvalue(res, row , 0));
int pid = atoi(PQgetvalue(res, row , 1));
int cid = atoi(PQgetvalue(res, row , 2));
int dur = atoi(PQgetvalue(res, row , 4));
bool lab = !strcmp ( PQgetvalue(res, row , 5), "t" );
Professor* p = GetProfessorById( pid );
Course* c = GetCourseById( cid );
for (row1=0; row1<rec_countgr; row1++) {
//.........这里部分代码省略.........