Jojo said:
It doesn't have to be NULL to crash. It could point to delete'd memory,
it could just point to an uninitialized object.
Yes, IOW, invalid.
"Valid" program doesn't make any sense.
Really? Makes no sense to you, eh? Strange. The entire C++ language
Standard is written that describes valid programs. If there were no
valid programs, or the concept would make no sense, we'd have no language
Standard. Yet we do. Everybody involved in it probably is out of their
mind.
> If everyone wrote 100% perfect
"valid" code then nothing would ever crash and we would all be running
perfect software.
No. There are other errors. Like overflow. Division by zero. Absence
of a file when you try opening it. And so on, without end. And those
situations need to be dealt with _after_ the program that deals with them
is made _valid_.
Yes, a valid program shouldn't "crash". And I bet there are programs that
just do not crash. They report critical situations, work their way out of
them, and so on.
> Never happens and is the reason why people invent
"safe" languages like Java et al.
No trolling here, please.
> For this reason references do not
make your code inherently safer (or even better) as you implied.
Yes, they do. If I never write any pointer-based code (which is possible)
and instead rely on the libraries supplied with the compiler to do it
correctly, I needn't worry about problems with references. My code is
safe as long as I don't hang onto references that can become invalid.
Yes and I'm adding that it's impossible not to deal with pointers.
I do not agree.
---------------------------
#include <iostream>
int main() {
std::cout << "Hello world" << std::endl;
}