-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshapes.h
More file actions
executable file
·28 lines (21 loc) · 836 Bytes
/
shapes.h
File metadata and controls
executable file
·28 lines (21 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef SHAPES_H
#define SHAPES_H
// A struct is a way of defining a new data type.
// In C/C++, we have int, double, char etc.
// We can also define a new data type by grouping several items together
// and giving each part of the struct a name.
// The parts of a struct are called "members" of that struct
struct Point {
double x;
double y;
}; // Now we can declare data items of type "struct Point".
// Don't forget the closing semicolon on your struct definitions.
// We are going to define a Box as a special case of a Rectangle.
// What is special about a Box is that its sides are parallel to
// x and y axes. Note that we can have a struct inside a struct!
struct Box {
Point ul; // upper left corner
double width;
double height;
}; // Now we can declare data items of type "struct Box"
#endif // SHAPES_H