User forums > Help
NULL undefined
wwolf:
Well, you know, everybody is good for something. If nothing else, one can serve as a bad example.
BTW if you had paid attention to a bit more than the (impossible to get from writing) emotions, and concentrated on meaning instead of (imagined) motivation, you would have seen that my references to those people were merely serving the purpose of showing that I know what I am talking about. Since it seemed that it was not a widely held view. :>
And if you carefully read my posts you will not find any place where I had asked anyone to look at me. None of the posters here deserved that harsh punishment. BTW you are the first one in my whole life who have called me a poser. So you are either a genius who can see what nobody else can, or you are plain wrong. ;) I can live with either. :>
Attila a.k.a. WW
insolence:
Certainly whether or not NULL is defined is something that can be clarified by looking at the latest published standards.
But separate from this issue I would say that beginners should not be discouraged nor perhaps encouraged from using NULL or macros or anything else.
Admittedly I come from a C, not a C++ background, but its more important that your code be readable and understandable to you and those maintaining it, then that you adhere slavishly to one prominent programmer or another's advice. If you use macros or NULL to do this, there's nothing wrong with that.
"gotos" in C are considered generally very ugly as they create code that is difficult to debug. But there is STILL a use for them. (C++ has try and catch to serve part of this need.) But what I think should be most clear from this debate is that different people have different coding styles and a beginner must find their own.
thomas:
--- Quote from: killerbot on September 16, 2007, 10:01:41 am ---If I recall correctly, they are thinking about a *template* for something like nullptr, but I am not sure.
--- End quote ---
You're going to laugh... for some reason, I woke up this morning and had an implementation of nullptr in my mind.
It works exactly like it should, and it is so ridiculously easy that I just had to put it into prep.h :)
thomas:
Ok, forgot about multiple definitions... will fix in a minute. :)
EDIT:
With the header being included a thousand times, it gets slightly more complicated, i.e. a .cpp file and an extern declaration are needed, but... it works :)
As a sidenote, doing a global file search for NULL, I noticed that NULL in Code::Blocks occurs in a lot of places where it is actually useless in my opinion, such as in all manager classes:
EditorColourSet* GetColourSet(){ return (this==NULL) ? 0 : m_Theme; }
Unless I have a gross misunderstanding, this cannot possibly be NULL, as all managers are singleton classes. Even if there was the possibility of calling a non-static member function on an uninitialised object, then this would not necessarily be NULL either (but some random, uninitialised value).
killerbot:
@Thomas, don't forget to adjust both Cb cbp's and makefile.am for the added nullptr.cpp file
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version