Skip to content

Commit 688e9d2

Browse files
authored
Adds initial topic for definitions (#76)
resolves #2
1 parent 692ff45 commit 688e9d2

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

sources/knowledge_areas.dat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ P Preprocessor
1212
? ? ? ? Macros
1313
B Basics Types, Objects, Values, Expressions, Statements, and Control-Flow Constructs
1414
? ? ? ? Constant Objects
15-
? ? ? ? Declarations and Definitions
15+
? ? ? ? Declarations
16+
def y y y Definitions
1617
? ? ? ? Selection Constructs (e.g., if, ternary)
1718
? ? ? ? Looping Constructs (e.g., for, while, etc.)
1819
F Functions
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
## C++ object model: Definitions {#def}
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
### Overview
7+
8+
_Provides a short natural language abstract of the module’s contents._
9+
_Specifies the different levels of teaching._
10+
11+
------------------------------------------------------------------------
12+
Level Objective
13+
----------------- ------------------------------------------------------
14+
Foundational Defining variables and ODR
15+
16+
Main Defining for programs
17+
18+
Advanced Special cases and peculiarities
19+
20+
------------------------------------------------------------------------
21+
22+
### Motivation
23+
24+
_Why is this important?_
25+
_Why do we want to learn/teach this topic?_
26+
27+
* A definition is a declaration that supplies all that is needed for a complete entity
28+
* `int baz = 42;`
29+
* `void bar() { /* implementation */ }`
30+
* `class Foo { /* class body */ };`
31+
32+
### Topic introduction
33+
34+
_Very brief introduction to the topic._
35+
36+
A definition extends a declaration, providing all that is needed for a complete
37+
entity, e.g., allocate memory for variables, provide the implementation for
38+
functions, complete definitions of data and function members of a class.
39+
40+
### Foundational: Defining variables and ODR {#def-found}
41+
42+
43+
#### Background/Required Knowledge
44+
45+
46+
A student:
47+
48+
* is familiar with declarations [[C++ object model: declarations]][1]
49+
50+
#### Student outcomes
51+
52+
_A list of things "a student should be able to" after the curriculum._
53+
_The next word should be an action word and testable in an exam._
54+
_Max 5 items._
55+
56+
A student should be able to:
57+
58+
1. define a variable with a specific type `int baz = 42;`
59+
2. define a function `void bar() {}`
60+
3. define a class `class Foo {};`
61+
4. explain the one definition rule
62+
63+
64+
#### Caveats
65+
66+
_This section mentions subtle points to understand, like anything resulting in
67+
implementation-defined, unspecified, or undefined behavior._
68+
69+
No caveats at present.
70+
71+
#### Points to cover
72+
73+
_This section lists important details for each point._
74+
75+
* One definition rule (ODR)
76+
77+
### Main: Defining for programs {#def-main}
78+
79+
80+
#### Background/Required Knowledge
81+
82+
83+
* All of the above.
84+
* is familiar with declarations [[C++ object model: declarations]][1]
85+
86+
#### Student outcomes
87+
88+
_A list of things "a student should be able to" after the curriculum._
89+
_The next word should be an action word and testable in an exam._
90+
_Max 5 items._
91+
92+
A student should be able to:
93+
94+
1. organize variables, functions, classes into multiple translation units, describing interface with declarations and providing the implementations with definitions without violating ODR.
95+
2. distinguish between template declaration and definition
96+
97+
#### Caveats
98+
99+
_This section mentions subtle points to understand, like anything resulting in
100+
implementation-defined, unspecified, or undefined behavior._
101+
102+
* Putting a definition into a header file that is included more than once leads to ODR violations, possibly resulting in linker errors.
103+
104+
#### Points to cover
105+
106+
_This section lists important details for each point._
107+
108+
### Advanced: Special cases and peculiarities {#def-advanced}
109+
110+
_These are important topics that are not expected to be covered but provide
111+
guidance where one can continue to investigate this topic in more depth._
112+
113+
* ABI Incompatibilities: Different definitions of the same type in multiple object files can lead to subtle program errors.
114+
115+
[1]: ../object-model/declarations.md

0 commit comments

Comments
 (0)