I think getline discards the delimiter (by default '\n') so you should be testing for "" instead of "\n".
Type: Posts; User: dandrestor
I think getline discards the delimiter (by default '\n') so you should be testing for "" instead of "\n".
What laserlight is advising is called RAII, and it's one of the fundamental things to learn in C++.
Refactoring a 900-line, non-repetitive function into smaller functions does not only split the text into regions, like paragraphs would. The important benefit in doing this decomposition is the...
I disagree, debugging 900 lines of code sharing the same state is totally different than debugging 90 chunks of 10 lines, each with its own state, preconditions, postconditions and invariants.
Laserlight is absolutely right. While minimizing function length is not a goal in itself, I think decomposing the problem into manageable, non-repetitive and easily debuggable chunks will lead to...
Good point! I didn't know that, thanks!
Glad you could make it work. There are many good habits that you should learn, especially if you're just starting programming. Search on the net, there's a ton of good literature out there....
In that case, the answer is simply "no, you can't have a virtual default-destructor without writing any code, because the default destructor is implicitly non-virtual", as the OP noticed.
The...
You can try Boost Tokenizer (Boost Tokenizer Overview - 1.36.0).
Alternatively, try std::string::find and std::string::substr.
break will only break out of the innermost for loop. Try return instead.
Also, make sure you initialize your variable. This will also eliminate the need for that last "if" statement (which has no...
Thanks for your thoughts. I am going down the path of one header with multiple implementations, perhaps hidden behind a pimpl.
I haven't fully read your source code, but at first glance I see that you have a lot of code duplication in your main do/while game loop.
I would do something like:
bool over = false;
int...
In C++11, you can declare a default virtual destructor, by writing
class Foo {
virtual ~Foo() = default;
};
HTH,
Dan
Plus, using const while passing by value should be avoided anyway.
Hello everybody! This is my first post on this forum.
I am writing a program that aims to be cross-platform, so it supports multiple low-level implementations for certain operations. My initial...