本文整理汇总了C++中Student::getAge方法的典型用法代码示例。如果您正苦于以下问题:C++ Student::getAge方法的具体用法?C++ Student::getAge怎么用?C++ Student::getAge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::getAge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// setFirst
TEST(StudentClass, STUDENT_CLASS_5) {
const char *first = "";
const char *ssn = "";
const char *text_short = "1234567890";
const char *text_long = "123456789012345678901234567890123456789012345678901234567890123";
const char *text_long1 = "1234567890123456789012345678901234567890123456789012345678901234";
const char *text_long2 = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
Student s;
EXPECT_EQ(s.getAge(), 0);
EXPECT_EQ(s.getLast(), (void *)0);
EXPECT_EQ(s.getFirst(), (void *)0);
EXPECT_EQ(s.getEmail(), (void *)0);
EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);
s.setFirst(text_short);
EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
s.setFirst(first);
EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
s.setFirst(text_long);
EXPECT_EQ(std::strcmp(s.getFirst(), text_long), 0);
s.setFirst(0);
EXPECT_EQ(s.getFirst(), (void *)0);
s.setFirst(text_long1);
EXPECT_EQ(std::strcmp(s.getFirst(), text_long1), 0);
s.setFirst(text_long2);
EXPECT_EQ(std::strcmp(s.getFirst(), text_long2), 0);
s.setFirst(text_short);
EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
s.setFirst(0);
EXPECT_EQ(s.getFirst(), (void *)0);
}
示例2: s
// assignment operator
TEST(StudentClass, STUDENT_CLASS_14) {
const int age = 1;
const char *last = "a";
const char *first = "b";
const char *email = "c";
const char *ssn = "999-99-9999";
const Student s(age, last, first, email, ssn);
EXPECT_EQ(s.getAge(), age);
EXPECT_EQ(std::strcmp(s.getLast(), last), 0);
EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
EXPECT_EQ(std::strcmp(s.getEmail(), email), 0);
EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);
Student t;
t = s;
EXPECT_EQ(t.getAge(), age);
EXPECT_EQ(std::strcmp(t.getLast(), last), 0);
EXPECT_EQ(std::strcmp(t.getFirst(), first), 0);
EXPECT_EQ(std::strcmp(t.getEmail(), email), 0);
EXPECT_EQ(std::strcmp(t.getSsn(), ssn), 0);
EXPECT_NE(t.getLast(), s.getLast());
EXPECT_NE(t.getFirst(), s.getFirst());
EXPECT_NE(t.getEmail(), s.getEmail());
EXPECT_NE(t.getSsn(), s.getSsn());
}
示例3: checkTeam
bool Team::checkTeam() const {
Student* student;
int age;
University* studentUniversity;
int captainCount = 0;
int studentCount = 0;
float totalAge = 0;
cout << "HELLO" << endl;
for (int i=0; i<4; i++){
student = students[i];
if (student == 0){
continue;
}
cout << student->getName() << endl;
studentCount += 1;
age = student->getAge();
if ((age < 18) || (age > 40)){
return false;
}
totalAge += (float) age;
if (student->getCaptain()){
captainCount++;
}
studentUniversity = &student->getUniversity();
if (studentUniversity == 0){
return false;
}
if (*studentUniversity != *university){
return false;
}
}
if (captainCount != 1) return false;
if (studentCount != 4) return false;
if (totalAge/4 > 24) return false;
return true;
}
示例4: AddStudents
void AcademyGroup::AddStudents(Student & add){
if (count % sizof == 0 && count != 0){
Student **pStTemp = new Student*[count + sizof]; if (!pStTemp) { exit(0); }
int i;
for (i = 0; i < count; i++){
pStTemp[i] = pSt[i];
}
delete[] pSt;
pSt = pStTemp;
for (; i < count + sizof; i++){
pSt[i] = new Student; if (!pSt[i]) { exit(0); }
}
}
delete pSt[count];
pSt[count] = new Student(add.getName(), add.getSurname(), add.getAge(), add.getPhone(), add.getAverage()); if (!pSt[count]) { exit(0); }
count++;
}