For me, this is only a venial sin against the spirit of OO.
And a goto does make nothing clearer.
But when you only jump down to the return, you should miss no variables?
Sorry if I miss something obvious.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
We use goto a lot in functions that call other functions returning error codes.
suppose some pseudo-code like this...
if string pointer is null or string is empty
set error code
if file can not be opened
set error code
if file read error happens
set error code
if memory allocation for structure fails
set error code
if file opened
If you declare file handles, etc. as you need them, then the compiler will complain that the 'initialization' of the type was skipped by the goto.
In this case, the if statments would have only nested 5 levels deep ... ugh.
But in soeem of our more complex processing, there might be 15-20 function calls which might fail before the actual 'work' begins.
I WISH we were all OO - parts of this code base are untouched since the days of our company founders - back in 1989!
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
The question was about the difference between using typedef and #define for defining types, not about variable usage. I would say to use whatever style is clearest and most appropriate for your situation - I don't dictate that certain styles are evil. I have no problems with using all the features of a language (including goto...) if it is the most appropriate way of attacking a certain problem.
Besides, you seem to have misread that part of the question - that code sample is the expansion of the macro definition given before it...
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late"John Nichol "Point Of Impact"
Well for me it's pretty strange that someone wants to write another string class... there are thousands of them flying around. I'm a fan of sticking to the standard one (especially with the boost additions).
But every one his own's.
For operator overloading I would consult "The c++ programming language" from Bjarne Stroustrup.
I can't give you a real pointer for looking up some information to Unicode - ANSI because you didn't specify it more.
Well.. maybe some thoughts.
All the label says is that this stuff contains chemicals "... known to the State of California to cause cancer in rats and low-income test subjects." Roger Wright http://www.codeproject.com/lounge.asp?select=965687&exp=5&fr=1#xx965687xx
In C++ deleting a NULL pointer is a NOP - It is fine to do so.
You comment about a double delete is correct but only works if you NULL it after deleting it:
CSomeObject* pObj = SomeFunction();<br />
// Later...<br />
delete pObj;<br />
pObj = NULL; // NULL it so we can't accidently delete it again!<br />// Later...<br />
delete pObj; // This is a NOP, no need for an if.
I am using NI graph in some application .I need to get the height and width of the plot area of the graph like not the controls height and width its on the control some area will be used to plot the graph .I used the line below but its returning zero is there any alternative mathod
long lHeight = GraphPtr->GetPlotAreaImage().GetHeight();
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
I am lnking a static library in my application. On linking i am getting the following errors. I compiled my application with /MDd and /MD switches.
This is errors text that i am getting on building my application.
I am able to successfuly build my application when i link with my static library (which is built in debug option). But unfortunately i am not able to successfully execute my application when i link with static library(which is built in release mode). When i am debugging it is giving the following error
user breakpoint called from code 0x77f9193c.
Any help in this regard
Last Visit: 31-Dec-99 18:00 Last Update: 6-Jul-22 0:50