Skip to content

Commit 4b7bf59

Browse files
committed
added drill14 for chapter13
1 parent 90dff0d commit 4b7bf59

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Chapter13/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ Write a function `sloping_cos()` that adds a cosine to `slope()` (as defined abo
4343

4444
## [Drill 13](drill/13)
4545
Define a `struct Person` containing a `string` name and an `int` age.
46+
47+
## [Drill 14](drill/14)
48+
Define a variable of type `Person`, initialize it with "Goofy" and 63, and write it to the screen (`cout`).

Chapter13/drill/14/Person.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef PERSON_H
2+
#define PERSON_H
3+
4+
#include <string>
5+
6+
struct Person {
7+
std::string name;
8+
int age;
9+
};
10+
11+
#endif

Chapter13/drill/14/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "Person.h"
2+
3+
#include <iostream>
4+
5+
int main() {
6+
Person p{"Goofy", 63};
7+
std::cout << p.name << ' ' << p.age << '\n';
8+
}

0 commit comments

Comments
 (0)