Skip to content

Commit

Permalink
updates to week3A
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtournier committed Jan 7, 2025
1 parent 4d78562 commit e67b685
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions week3A.md
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ Now let's add some data members to our class:
class ShotgunSequencer {
private:
int m_minimum_overlap;
const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
Expand All @@ -1237,7 +1237,7 @@ class ShotgunSequencer {
class ShotgunSequencer {
`private:`
int m_minimum_overlap;
const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
Expand All @@ -1253,7 +1253,7 @@ class ShotgunSequencer {
class ShotgunSequencer {
private:
* int m_minimum_overlap;
* const int m_minimum_overlap = 10;
* std::string m_sequence;
* Fragments m_fragments;
};
Expand All @@ -1263,6 +1263,31 @@ class ShotgunSequencer {
- all subsequent declarations will be private
- we can now declare our member variables, in exactly the same way as we did
with `struct`
- there are many naming conventions – for member variables, we
recommend `snake_case` with the `m_` prefix

---

```
class ShotgunSequencer {
private:
* const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
```
- we are going to declare our member variables as **private**
- this is done using the `private` keyword, followed by a colon (`:`)
- all subsequent declarations will be private
- we can now declare our member variables, in exactly the same way as we did
with `struct`
- there are many naming conventions – for member variables, we
recommend `snake_case` with the `m_` prefix
- note that member variables can be *default-initialised* as shown
- this type of initialisation was introduced in C++11
- we need to initialise `m_minimum_overlap` since we have declared it
`const` – we won't be able to modify it later!

---
layout: true
Expand All @@ -1281,7 +1306,7 @@ class ShotgunSequencer {
void check_remaining_fragments ();
private:
int m_minimum_overlap;
const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
Expand All @@ -1297,7 +1322,7 @@ class ShotgunSequencer {
void check_remaining_fragments ();
private:
int m_minimum_overlap;
const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
Expand All @@ -1316,7 +1341,7 @@ class ShotgunSequencer {
* void check_remaining_fragments ();
private:
int m_minimum_overlap;
const int m_minimum_overlap = 10;
std::string m_sequence;
Fragments m_fragments;
};
Expand All @@ -1328,6 +1353,10 @@ class ShotgunSequencer {
- these look very similar to regular function declarations
- ... but they are declared within the scope of our `ShotgunSequencer` class





---
layout: false

Expand Down

0 comments on commit e67b685

Please sign in to comment.