This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// testing how many threads work in c++ | |
// spoiler alert: at least 2000 work, probably more | |
#include <thread> | |
#include <iostream> | |
#include <chrono> | |
#include <vector> | |
void count(int threadNumber){ | |
// Function that counts 5 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// showing how copying an instance of a class | |
// doesn't copy the dynamically allocated variables, | |
// it simply copies over their address. So the new | |
// copy shares the old variable. | |
#include <iostream> | |
class Thing{ | |
public: | |
Thing(){ pInt = new int; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// explanation: | |
// Defines 3 classes: Parent, Child, and Thing. | |
// Thing takes in a parent into its constructor. | |
// Parent initializes a Thing in its constructor using 'this.' | |
// Child does nothing but initialize Parent(). | |
// | |
// main initializes a Child class, and calls a function from Thing. | |
// Thing, which was initialized using 'this' in the parent constructor, | |
// uses that 'this' to refer to the Child, not the Parent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <map> | |
#include <vector> | |
int main() | |
{ | |
// a map is a really good way to keep track of information. | |
// if the key doesn't exist, it will be created. | |
// if the key does exist, it will just reassign the value |