本文整理汇总了C++中Person类的典型用法代码示例。如果您正苦于以下问题:C++ Person类的具体用法?C++ Person怎么用?C++ Person使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Person类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_func
void test_func(void)
{
//Person *p = new Person();
Person per;
per.printInfo();
}
示例2: main
/**********************************************************************
* Add text here to describe what the function "main" does. Also don't forget
* to fill this out with meaningful text or YOU WILL LOSE POINTS.
***********************************************************************/
int main(int argc, const char* argv[])
{
//change this back to 2 to be universal
if (argc < 1)
{
cout << "Usage: a.out fileName\n";
}
else
{
List<Person> people;
ifstream fin;
//string fileName = argv[1];
string fileName = "cameron.ged";
string tmp;
//Read in file
do
{
fin.clear();
fin.open(fileName.c_str());
}
while(fin.fail());
Person person;
//parse file into list
while(getline(fin, tmp))
{
if(tmp.substr(0,4) == "0 @I")
{
person.idNumber = tmp.substr(4,4);
fin.ignore();
}
if(tmp.substr(0,6) == "2 GIVN")
{
person.fname = tmp.substr(6);
}
if(tmp.substr(0,6) == "2 SURN")
{
person.lname = tmp.substr(6);
}
if(tmp.substr(0,6) == "1 BIRT")
{
getline(fin, tmp);
if(tmp.substr(0,6) == "2 DATE")
{
person.bday = tmp.substr(6);
}
}
if(tmp.substr(0,6) == "3 TIME")
{
people.push_back(person);
person.clear();
}
}
sortMerge(people);
for(ListIterator<Person> it = people.begin(); it != people.end(); it++)
{
(*it).display();
}
//cout << tmp << endl;
//organize by name
//Put into tree
//output
}
return 0;
}
示例3: if
void QBorderMainWindow::performFaceVerification(int isSketch) {
//verify each input face with the wantedPersons.
commonTool.log("Performing face verification");
// commonTool.log("222222333"+QString::number(wantedPersonsSynthesized.size()));
matchedIndex = -1;
partialMatchedIndex = -1;
if (!inputPerson.empty()) {
faceVerificationResult.clear();
partialFaceVerificationResult.clear();
sortedPartialFaceVerificationResult.clear();
sortedFaceVerificationResult.clear();
faceVerificationResultRaw.clear();
persons.clear();
for (int i=0;i<(int)wantedPersons.size();i++) {
std::vector<double> similarities;
// commonTool.log("222222333"+QString::number(wantedPersonsSynthesized.size()));
/*
if (!wantedPersonsSynthesized.at(i).empty()) {
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPerson);
commonTool.log(QString("%1 -> %2*").arg(i).arg(similarities.at(0)));
} else {
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPerson);
commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0)));
}
*/
//Audrey
//commonTool.log("QBorderMainWindow::faceInputSynthesizeCompleted()");
//synthesize the input face now
if (isSketch == 1 && inputPersonSynthesizedReady) {
if (!wantedPersonsSynthesized.at(i).empty()) {
// commonTool.log("1111111");
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPersonSynthesized);
// commonTool.log(QString("%1 -> %2*").arg(i).arg(similarities.at(0)));
} else {
// commonTool.log("2222222"+QString::number(wantedPersonsSynthesized.size()) + "EE" + QString::number(i));
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPersonSynthesized);
// commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0)));
}
} else if (!wantedPersonsSynthesized.at(i).empty()) {
commonTool.log("3333333");
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPerson);
commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0)));
} else {
commonTool.log("4444444");
similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPerson);
commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0)));
}
commonTool.log(QString("numberOfSimilarityScores = %1").arg(similarities.size()));
Person person;
IntDouble full;
full.i = i;
full.confidence = 100.0;
full.d = similarities.at(0);
faceVerificationResult.push_back(full);
faceVerificationResultRaw.push_back(similarities);
person.setFull(full);
//partial score ...
//
commonTool.log("clac partial score.");
IntDouble partial;
partial.i = i;
partial.confidence = 0.0;
partial.d = 0.0;
int c=0;
if (similarities.at(0) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 100.0;
partial.d += similarities.at(0);
}
if (c==0) {
if (similarities.at(1) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 50.0;
partial.d += similarities.at(1);
}
if (similarities.at(2) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 50.0;
partial.d += similarities.at(2);
} if (c==0) {
if (similarities.at(3) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 25.0;
partial.d += similarities.at(3);
}
if (similarities.at(4) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 25.0;
partial.d += similarities.at(4);
}
if (similarities.at(5) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 25.0;
partial.d += similarities.at(5);
}
if (similarities.at(6) > faceMatchingManager.alarmThreshold) {
c++;
partial.confidence += 25.0;
//.........这里部分代码省略.........
示例4: deref_ok
int deref_ok() {
Person p;
return p.access_age();
}
示例5: modify
Person modify( vector<Person>& people ) { // User menu that changes a persons template for the modify person operation
QTextStream in(stdin);
Person temp;
string gender;
QString birth, death, name, numId;
char modify;
int id = 0;
cout << "Select a person to modify(input the number displayed before the name): ";
while( !(id > 0 && id <= int( people.size() ) )) {
numId = in.readLine();
id = numId.toInt();
}
temp = people[id-1];
cout << " 1. Name\n" <<
" 2. Gender\n" <<
" 3. Birth date\n" <<
" 4. Death date\n" <<
" 5. All" << endl;
cout << "What would you like to modify: ";
cin >> modify;
switch( modify ) {
case '1': //To modify name only
cout << "Name: ";
cin.ignore();
name = "";
while( name == "" )
name = in.readLine();
temp.setName( name );
break;
case '2': //To modify gender only
cout << "Gender(male/female): ";
do{
cin >> gender;
cin.ignore();
if(gender == "male" || gender == "Male")
temp.setGender( 1 );
else if(gender == "female" || gender == "Female")
temp.setGender( 2 );
else
cout << "Not a valid entry!";
} while( !(temp.getGender( ) == 1 || temp.getGender( ) == 2) );
break;
case '3': //To modify birth year only
do{
cout << "Birth year(dd.mm.yyyy): ";
birth = in.readLine();
temp.setBirth( QDate::fromString( birth, "dd.MM.yyyy" ) );
if( !(temp.getBirth().isValid()) )
cout <<"Not a valid date!"<< endl;
}while( !(temp.getBirth().isValid()) );
break;
case '4': //To modify death year only
do{
cout << "Death year(dd.mm.yyyy, enter 0 if person is still alive): ";
death = in.readLine();
temp.setDeath( QDate::fromString( death, "dd.MM.yyyy" ) );
if( death == "0" )
break;
if( !(temp.getDeath().isValid()) )
cout <<"Not a valid date!" << endl;
}while( !(temp.getDeath().isValid()) );
break;
case '5': //To modify all
temp = addPerson();
break;
default:
cout << "Not a valid option" << endl;
break;
}
temp.setId( people[id-1].getId() );
cout << endl;
return temp;
}
示例6: dispatcher
void ReturnToNormalPopulationEvent::execute() {
Person* person = (Person*) dispatcher();
person->return_to_normal_population();
}
示例7: RGB
void CMyTable::Draw(CDC* pDC, MyCollection* coll)
{
//pDC->MoveTo(X, Y);
int startX = X, startY = Y + cellHeight, finishX, finishY;
CRect rect;
CPen aPen;
aPen.CreatePen(PS_SOLID, 1, RGB(150, 150, 150));
CPen* oldPen;
oldPen = pDC->SelectObject(&aPen);
coll->startPos = true;
sumCell = 0;
for(int i = 0; i < coll->GetLength(); i++)
{
Person* p = coll->getPerson();
if(p == NULL)break;
sumCell++;
finishY = startY + cellHeight;
for(int j = 0; j < 5; j++)
{
if(j == 0)
{
finishX = startX + 340;
rect.SetRect(startX, startY, finishX + 1, finishY + 1);
pDC->Rectangle(&rect);
rect.SetRect(startX + 20, startY, finishX + 20 + 1, finishY + 1);
pDC->SetTextColor(RGB(20, 20, 20));
pDC->DrawTextW(p->getInitial(), &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP);
//pDC->SelectObject(oldPen);
}
if(j == 1)
{
startX = finishX;
finishX = startX + 145;
rect.SetRect(startX, startY, finishX + 1, finishY + 1);
pDC->Rectangle(&rect);
CString str = p->ToCString(p->getSumHours());
pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP);
}
if(j == 2)
{
startX = finishX;
finishX = startX + 145;
rect.SetRect(startX, startY, finishX + 1, finishY + 1);
pDC->Rectangle(&rect);
CString str = p->ToCString(p->getTarif());
str = str + ' ' + 'p';
pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP);
}
if(j == 3)
{
startX = finishX;
finishX = startX + 340;
rect.SetRect(startX, startY, finishX + 1, finishY + 1);
pDC->Rectangle(&rect);
CString str = p->ToCString(p->getSalary());
str = str + ' ' + 'p';
pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP);
}
if(j == 4)
{
startX = finishX;
finishX = startX + 340;
rect.SetRect(startX, startY, finishX + 1, finishY + 1);
pDC->Rectangle(&rect);
CString str = p->ToCString(p->getId());
pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP);
}
}
startX = X;
startY += cellHeight;
}
pDC->SelectObject(oldPen);
}
示例8: sortName
void sortName(Person& a, Person& b)
{
if(a.getName() < b.getName())
switching(a, b);
}
示例9: main
//.........这里部分代码省略.........
// If frame is empty break
if ( frame.empty() )
{
break;
}
//cv::pyrDown(frame,frame);
// Specify the roi that will be extracted from the frame
roi.x = marginLeft; // pixels to skip from the left
roi.y = marginTop; // pixels to skip from the top
roi.width = frame.cols-roi.x-marginRight; // width of roi
roi.height = frame.rows-roi.y-marginBottom; // height of roi
// Change settings if required
// Proces current image.
// Process function evaluates the frames contents and
// must be called before getCurrentPeople();
//show the current face image
//cv::imshow("frame",frame);
//namedWindow( "frame", CV_WINDOW_KEEPRATIO );
if ( !crowdsight.process(frame,roi) )
{
std::cout << crowdsight.getErrorDescription() << std::endl;
}
// Get the list of people in the last processed frame
std::vector<Person> people;
if ( !crowdsight.getCurrentPeople(people) )
{
std::cerr << crowdsight.getErrorDescription() << std::endl;
}
cout<<"outer counter "<<counter++<<endl;
// For the one person in the frame, do:
if (people.size()>0 )
{
cout<<"inner counter "<<icounter++<<endl;// Get person
Person person = people.at(0);
/*********************************** RETRIEVE PERSN INFO ***********************************/
cv::Rect face = person.getFaceRect(); // Retrieve the person's face
cv::Point right_eye = person.getRightEye(); // Retrieve left and right eye locations of the person. Eye location is relative to the face rectangle.
cv::Point left_eye = person.getLeftEye();
/************************************* DRAW PERSON INFO *************************************/
// Offset eye position with face position, to get frame coordinates.
right_eye.x += face.x;
right_eye.y += face.y;
left_eye.x += face.x;
left_eye.y += face.y;
// Draw circles in the center of left and right eyes
//cv::circle( frame, right_eye, 3, cv::Scalar(0,255,0) );
//cv::circle( frame, left_eye, 3, cv::Scalar(0,255,0) );
Mat faceRect=frame(face);
// Draw a rectangle around person's face on the current frame
//cv::rectangle(frame, face, cv::Scalar(255,255,255), 1);
示例10: main
int main()
{
int nperson, nquery;
scanf("%d %d", &nperson, &nquery);
vector<vector<Person>> table(201);
vector<int> index(201, 0);
for(int i=0; i<nperson; i++)
{
Person p;
scanf("%s %d %d", p.name, &p.age, &p.worth);
table[p.age].push_back(p);
}
for( int i=0,size=table.size(); i<size; i++)
{
sort(table[i].begin(), table[i].end());
}
for(int i=1; i<=nquery; i++)
{
int agemin, agemax, k;
scanf("%d %d %d", &k, &agemin, &agemax);
printf("Case #%d:\n", i);
int K = 0;
for(int j=agemin; j<=agemax; j++)
{
index[j] = 0;
}
Person minp;
int minindex;
while(true)
{
bool reachend = true;
minp.worth = -1000001;
for( int j=agemin; j<=agemax; j++)
{
if( index[j] >= table[j].size())
{
}
else
{
reachend = false;
if( table[j][index[j]] < minp)
{
minindex = j;
minp = table[j][index[j]];
}
}
}
if( reachend)
{
if( !K)
{
printf("None\n");
}
break;
}
else
{
minp.print();
index[minindex]++;
if( ++K == k)
{
break;
}
}
}
}
return 0;
}
示例11: drawScene
//.........这里部分代码省略.........
{
gifts_x2=hh%8;
gifts_z2=hh/8;
p1.gifts(i+1.5,j);
}*/
glPushMatrix();
glTranslatef(i+1.5,0.0,j);
glCallList(_displayListId_whiteArea);
glPopMatrix();
}
}
}
}
}
else if(mode == 0)
{
for(float j=0.0;j>(-8*1.5);j-=1.5)
{
k++;
for(i=0.0;i<(4*3.0);i+=3.0)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, grassTextureId);
//Bottom
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if(k%2==0)
{
glPushMatrix();
glTranslatef(i,0.0,j);
glCallList(_displayListId_blackArea);
glPopMatrix();
}
else
{
glPushMatrix();
glTranslatef(i+1.5,0.0,j);
glCallList(_displayListId_blackArea);
glPopMatrix();
}
}
}
for(float j=0.0;j>(-8*1.5);j-=1.5)
{
k++;
for(i=0.0;i<(4*3.0);i+=3.0)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, grassTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if(k%2!=0)
{
glPushMatrix();
glTranslatef(i,0.0,j);
glCallList(_displayListId_whiteArea);
glPopMatrix();
}
else
{
glPushMatrix();
glTranslatef(i+1.5,0.0,j);
glCallList(_displayListId_whiteArea);
glPopMatrix();
}
}
}
}
if(mode == 0 || mode ==1)
{
if((tile_x1 == sx && tile_z1 == sz) ||( tile_x2 == sx && tile_z2 == sz) || (sx < 0) || (sx > 7) || (sz < 0) || (sz > 7))
{
flag_exit = 1;
}
if((sx == obs_x1 && sz == obs_z1) || (sx == obs_x2 && sz == obs_z2))
{
printf("You are DEAD !!!\nLOL!!!!!\n");
exit(0);
}
}
glPushMatrix();
glTranslatef(0.0f, 0.0f, -5.0f); // Push eveything 5 units back into the scene, otherwise we won't see the primitive
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
p1.drawPerson();
//p1.obstacle();
//p1.gifts(1,1);
glPopMatrix();
glutSwapBuffers();
angle++;
}
示例12: while
Person Person::Parser::parseXml(QXmlStreamReader &xml)
{
Person person;
bool hasAvatarPic = false;
while (!xml.atEnd()) {
xml.readNext();
if (xml.isStartElement()) {
if (xml.name() == QLatin1String("personid")) {
person.setId(xml.readElementText());
} else if (xml.name() == QLatin1String("firstname")) {
person.setFirstName(xml.readElementText());
} else if (xml.name() == QLatin1String("lastname")) {
person.setLastName(xml.readElementText());
} else if (xml.name() == QLatin1String("homepage")) {
person.setHomepage(xml.readElementText());
} else if (xml.name() == QLatin1String("avatarpic")) {
person.setAvatarUrl(QUrl(xml.readElementText()));
} else if (xml.name() == QLatin1String("avatarpicfound")) {
QString value = xml.readElementText();
if (value.toInt()) {
hasAvatarPic = true;
}
} else if (xml.name() == QLatin1String("birthday")) {
person.setBirthday(QDate::fromString(xml.readElementText(), Qt::ISODate));
} else if (xml.name() == QLatin1String("city")) {
person.setCity(xml.readElementText());
} else if (xml.name() == QLatin1String("country")) {
person.setCountry(xml.readElementText());
} else if (xml.name() == QLatin1String("latitude")) {
person.setLatitude(xml.readElementText().toFloat());
} else if (xml.name() == QLatin1String("longitude")) {
person.setLongitude(xml.readElementText().toFloat());
} else {
person.addExtendedAttribute(xml.name().toString(), xml.readElementText());
}
} else if (xml.isEndElement() && (xml.name() == QLatin1String("person") || xml.name() == QLatin1String("user"))) {
break;
}
}
if (!hasAvatarPic) {
person.setAvatarUrl(QUrl());
}
return person;
}
示例13: meet
void Person::meet(Person other) {
cout << "Hi " << other.name << ", my name is " << this->name <<endl;
other.giggleNervously();
other.seize();
}
示例14: sortGender
void sortGender(Person& a, Person& b)
{
if(a.getGender() < b.getGender())
switching(a, b);
}
示例15: SearchPersonMenu
Person SearchPersonMenu() { // Get search paramters from user
Person temp;
char key = 0;
QTextStream in(stdin);
temp.setName("");
temp.setGender(0);
while( key != '5' ) { // while looping while inserting search parameters
cout << "Please specify search parameters" << endl;
cout << "\t1. Search by name(";
if( temp.getName() == "" ) // If wildcard
cout << "any)" << endl;
else // if user specified
cout << temp.getName().toUtf8().constData() << ")" << endl; // Write current name parameters
cout << "\t2. Search by gender(";
if( temp.getGender() == 0 ) // If wildcard
cout << "any)" << endl;
else if( temp.getGender() == 1 ) // if user specified
cout << "male)" << endl;
else if( temp.getGender() == 2 ) // if user specified
cout << "female)" << endl;
cout << "\t3. Search by birth(";
if( !temp.getBirth().isValid() ) // If wildcard
cout << "any)" << endl;
else // if user specified
cout << temp.getBirth().toString("d.M.yyyy").toUtf8().constData() << ")" << endl; // Write current birth parameters
cout << "\t4. Search by death(";
if( !temp.getDeath().isValid() ) // If wildcard
cout << "any)" << endl;
else // if user specified
cout << temp.getDeath().toString("d.M.yyyy").toUtf8().constData() << ")" << endl; // Write current death parameters
cout << "\t5. Search" << endl;
cout << "Your choice: ";
cin >> key; // Get user input for next action, 1: name parameter, 2: gender parameter, 3: birth parameter, 4: death parameter and 5: Search
cin.ignore();
if( key == '1' ) { // Set user name search parameter
cout << "Insert name to search for: ";
temp.setName( in.readLine() );
} else if( key == '2' ) { // Set user gender search parameter
temp.setGender( -1 );
while( (temp.getGender() < 0) || (temp.getGender() > 2) ) {
QString gender;
cout << "Insert gender to search for(any/male/female): ";
gender = in.readLine();
if( gender == "any" || gender == "Any" )
temp.setGender( 0 );
else if( gender == "male" || gender == "Male" )
temp.setGender( 1 );
else if( gender == "female" || gender == "Female" )
temp.setGender( 2 );
else
cout << "Please enter a valid gender" << endl;
}
} else if( key == '3' ) { // Set user birth search parameter
QString birthstring = "";
temp.setBirth( QDate() ); // Set empty date (Also used as wildcard)
while( birthstring != "0" && !temp.getBirth().isValid() ) {
cout << "Insert birth date(dd.mm.yyyy, 0 for any): ";
birthstring = in.readLine();
if( birthstring != "0" )
temp.setBirth( QDate::fromString( birthstring, "dd.MM.yyyy" ) );
}
} else if( key == '4' ) { // Set user death search parameter
QString deathstring = "";
temp.setDeath( QDate() ); // Set empty date (Also used as wildcard)
while( deathstring != "0" && !temp.getDeath().isValid() ) {
cout << "Insert death date(dd.mm.yyyy, 0 for any): ";
deathstring = in.readLine();
if( deathstring != "0" )
temp.setDeath( QDate::fromString( deathstring, "dd.MM.yyyy" ) );
}
}
}
cout << endl;
return temp; // Returns template for person to search for
}