-
Notifications
You must be signed in to change notification settings - Fork 0
/
extra_notes.txt
16 lines (12 loc) · 951 Bytes
/
extra_notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
* What is a static member variable?
A static member variable means that the variable is shared between all instances of the class.
That means, instead of each instance having a copy of the variable, all instances share this variable.
It is often preferred to save space especially when the variable is an object of a class.
Likewise for static functions and classes. There is only one copy of the variable.
The idea is that creating and cleaning up the instances can be a computationally expensive process,
if it can be made static, it is a good idea to speed up execution of the program.
On the flip side, it can also be expensive to use a static variable.
If using a static variable requires the CPU to fetch the variable from slower memory,
rather than having it in the cache or stack. Each fetch from slower memory slows down execution time.
* using namespace std?
https://www.geeksforgeeks.org/using-namespace-std-considered-bad-practice/