My question is : how can i store the content of a .txt file in a char* is named m_str in c++?
Kindly note that my file has a very defined format that i want to keep. I dont want to merge the lines together. I want what is one line 1 to stay on line 1, and what is one line 2 to stay in line 2. B...
std::ifstream file("hello.txt");
if (file) {
std::vector<char> vec(std::istreambuf_iterator<char>(file),
(std::istreambuf_iterator<char>()));
} else {
// ...
}
Very elegant compared to the manual approach using a loop and push_back.
Inheritance is wonderful if your application domain really is hierarchical. But people seem to be forcing all kinds of strange things into hierarchies, and having hierarchies just for the sake of hierarchies. You have a lot of programmers who think that "object-oriented" means "never use a free-standing function". [...] Inheritance has been seriously overused for the last couple of decades.
You may move the "char* surface" to the templated SimulationObject and write down the generic implementation of the operateOnSurface() method right in the header file.
To distinguish between the Vector2D and Vector3D you may use the sizeof(). Yes, it might introduce some warnings, but the compil...
@RMartinhoFernandes It works because of lazyness, and you get an infinite loop if you evaluate a or b later. I guess it's important for that "tying the knot" business (getting doubly linked lists to work in a purely functional setting).