IT Nursery
My understanding is that string is a member of the std namespace, so why does the following occur? #include <iostream> int main() { using namespace std; string myString =...
  • June 3, 2022
  • 0 Comments
Is it possible in C++ to replace part of a string with another string? Basically, I would like to do this: QString string("hello $name"); string.replace("$name", "Somename"); But I would...
  • May 25, 2022
  • 0 Comments
I’m practicing using mulitple files and header files etc. So I have this project which takes two numbers and then adds them. Pretty simple. Here are my files: main.cpp...
  • May 24, 2022
  • 0 Comments
I’ve got code that looks like this: for (std::list<item*>::iterator i=items.begin();i!=items.end();i++) { bool isActive = (*i)->update(); //if (!isActive) // items.remove(*i); //else other_code_involving(*i); } items.remove_if(CheckItemNotActive); I’d like remove inactive items immediately...
  • May 19, 2022
  • 0 Comments
C++11 vectors have the new function emplace_back. Unlike push_back, which relies on compiler optimizations to avoid copies, emplace_back uses perfect forwarding to send the arguments directly to the constructor...
  • May 19, 2022
  • 0 Comments