mirror of
https://github.com/epasveer/seer.git
synced 2026-08-30 00:50:42 +08:00
Fixed structure recursion.
This commit is contained in:
@@ -21,11 +21,16 @@ struct Person {
|
||||
struct Location location;
|
||||
};
|
||||
|
||||
void print(const Location& where) {
|
||||
|
||||
std::cout << "From '" << where.city << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
|
||||
Person me;
|
||||
Person you;
|
||||
Location where;
|
||||
|
||||
me.name = "Pasveer, Ernie";
|
||||
me.age = 60;
|
||||
@@ -36,22 +41,21 @@ int main (int argc, char** argv) {
|
||||
me.location.cell = (Cell*)malloc(sizeof(Cell));
|
||||
me.location.cell->number = 2226669999;
|
||||
|
||||
you.name = "Pitt, Dirk";
|
||||
you.age = 60;
|
||||
you.salary = 0.25;
|
||||
you.location.city = "Houston";
|
||||
you.location.state = "Texas";
|
||||
you.location.zip = 77063;
|
||||
you.location.cell = (Cell*)malloc(sizeof(Cell));
|
||||
you.location.cell->number = 2226669999;
|
||||
where.city = "Houston";
|
||||
where.state = "Texas";
|
||||
where.zip = 77063;
|
||||
where.cell = (Cell*)malloc(sizeof(Cell));
|
||||
where.cell->number = 2226669999;
|
||||
|
||||
std::cout << "'" << me.name << "', from '" << me.location.city << "', is " << me.age << " years old and makes " << me.salary << " per year." << std::endl;
|
||||
|
||||
print(where);
|
||||
|
||||
free(me.location.cell);
|
||||
free(you.location.cell);
|
||||
free(where.cell);
|
||||
|
||||
me.location.cell = 0;
|
||||
you.location.cell = 0;
|
||||
where.cell = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user