Ad
  • Default User Avatar

    its just problem solving, i would recommend drawing out way to solve the problem on paper

  • Default User Avatar

    im not the best at c++ but from from my understanding he makes a lambda function called add which returns whatever is made hence auto which in this case will always be void, the [&] following captures all the variables within the scope by reference this causes add to have the vector times. Then (auto text, auto time) is the parameters that add takes which in the way he uses will just become (std::string text, int time). He has if (time == 0) return; so that he will not add unneeded thing to the vector in this case a time that is 0. if the if statment is not true it will continue and push_back time which is an int that he will convert to a std::string, it will add the text which will be " day", " hour" etc. finally if time is > 1 it will add a 's' to the back of the text to make sure that it is multiple since thats what the rules imply and if time is not > 1 it will add nothing. The ? and : is a type of conditional operator, sorry for the long explanation have a great day!

  • Default User Avatar

    This was a great problem couldnt solve it after a day of trying came back a week later and solved it in less then 10 mins!!

  • Default User Avatar

    auto just auto chooses the type at compile time
    examples
    auto num = 2 same as int num = 2