Imagine I have this code: class A { public: void GetInt() { cout << number << endl; } void SetInt(int n) { number = n; } private: int number = 0; }; class B : public A { public: void GetInt() { cout << number << endl; } private: int number = 0; }; int ..

Read more

How could I have my vector class to do this (something that the std::vector class can do) std::vector<int> thing = {1,2,3,4,5} So using the initializer list… I’ve tried something like this… dynamic_array(T&&… args) : buffer(new T[sifeof(args)…] {std::forward<T>(args)…}) , size(sizeof(args)…) , capacity(sizeof(args)…) { /* constructor things */ } Yeah, I know, I suck with variadic stuff ..

Read more

#include <iostream> #include <vector> #include <memory> #include <unordered_map> using namespace std; struct A { void what_type() { cout<<"A"<<endl; }}; struct B { void what_type() { cout<<"B"<<endl; }}; class MyCommonAncestor { }; template <class T> class MyTemplateClass : public MyCommonAncestor { public: std::unordered_map<int, T> myx; }; int main() { vector<shared_ptr<MyCommonAncestor>> myVector; myVector.push_back(make_shared<MyTemplateClass<A>>()); myVector.push_back(make_shared<MyTemplateClass<B>>()); for (auto& x: ..

Read more

so I’ve been doing my homework and I stumbled upon a problem. After I input part of the date for my program it just goes into an infinite loop. The idea is to create an array that consists of structure entries. I’m not sure where the problem seems to be coming from since it just ..

Read more

So I have this problem, when I try to add card using the operator that I created +=, for some reason there is a problem that the card that I try to add, is adding to all the people and not to the last player. Code Here I’m using the operator +=: for (int cardIdx ..

Read more