100DaysOfGameDev: Day 37

The missing puzzle pieces were lectures. I went back to this awesome C++ series and oh God I understand everything much better now. I need to hear the intonation of the voice when learning about something because it helps me get into the context and make correct assumptions that allow me to grasp the topic better. In the case of a book, the author types out the voice in their head on paper, and information is lost. Maybe he had a sarcastic voice while writing that example, but since I didn't hear it, I may take that example for granted and then get confused about future topics. I also like that in these lectures, because I would get confused on the parts where the lecturer or the chat got confused too. It gives me confidence that my idea, that something was off is verified by other people, and since I do not have enough expertise to figure out a solution on the spot they give an explanation anyway, which allows me to quickly proceed to other topics, without wasting of much time. Although, I still prefer to read the book in the beginning and turn back to lectures, when confused, so I can get most information. As a final word, I will leave these two examples which are different, and try to explain the concept of a template of a template parameter.

#include <vector>

template <typename T, template <typename> class Container = std::vector>
class Stack {
	Container<T> c;
public:

};

int main()
{
	Stack<int, std::vector> s;
	return 0;
}

where you can specify what type of container to use as an underlying data structure for the stack.

#include <vector>

template <typename T, typename Container = std::vector<T>>
class Stack {
	Container c;
public:

};

int main()
{
	Stack<int, std::vector<int>> s;
	return 0;
}

Also, note that when I tried to run these examples, they seemed to work on compilers from version C++17. Although, it didn't run with my Macbook's compiler, so I have no clue what can be the problem. That's it for today see you tomorrow!