Hi,i have a problem with this code ,it aborts but i don't know why,can any 1 help me?
#include
Hi! In the year class you have 2 constructors, when you create object "Y" with the statement year Y; the second constructor is called (the one that does nothing). So neither of "month" or "day" is constructed properly. When you access to "month" or "day", it will give unexpected results. I believe that the 2nd constructor was actually a destructor, you just forgot the "~" before it :) . Also, in the first contructor, you only initialized y, you did nothing to "month" and "day". Anyway, here is my code for the year class: class year { public: int y; vector<int> month ; vector<int> day ; year(){ y = 0; month = vector<int>(12); day = vector<int>(12); } ~year() { }; }; I hope it helps! :)
Join our real-time social learning platform and learn together with your friends!