C++... Reference Parameters

Started by
15 comments, last by Trashcann 20 years, 6 months ago
Why do people try to make wrong what is right?

I am also aware that in some implementations NULL is (void *) 0 which is still zero!

You can alter the default behaviour if you wish, but the facts are there, plain and simple. Read it, it says 'If unsuccessful, by default new returns zero.' How much more plain do you want?!

[edited by - mathematix on October 7, 2003 6:40:59 AM]
Advertisement
Mathematix: That''s only true for MSVC. (And probably only MSVC 6, seems like they fixed it in .NET)
There ARE other compilers, and some of them actually follow the spec. (which says that new either returns a non-null pointer, or throws bad_alloc, like spock said)
That''s the reason why it p***** me off posting here! Everybody is a bloody know-all until somebody dares to post something sensible, then try to crush it. It makes me sick.

I am aware of other compilers. Just one question, what on earth is the pointer set to once a bad_alloc exception is raised?
Undefined, mister.
quote:Original post by Mathematix
That''s the reason why it p***** me off posting here! Everybody is a bloody know-all until somebody dares to post something sensible, then try to crush it. It makes me sick.

I am aware of other compilers. Just one question, what on earth is the pointer set to once a bad_alloc exception is raised?


It depends on how the code is structured. If the exception is caught outside of the pointer''s scope then the pointer doesn''t even exist. If it''s caught inside the pointer''s scope then its value is probably undefined, though I don''t have my standard to hand to check.

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
quote:Original post by DrPizza
quote:Original post by Mathematix
That''s the reason why it p***** me off posting here! Everybody is a bloody know-all until somebody dares to post something sensible, then try to crush it. It makes me sick.

I am aware of other compilers. Just one question, what on earth is the pointer set to once a bad_alloc exception is raised?


It depends on how the code is structured. If the exception is caught outside of the pointer''s scope then the pointer doesn''t even exist. If it''s caught inside the pointer''s scope then its value is probably undefined, though I don''t have my standard to hand to check.

Thanks DrPizza! You are someone who at last has a damn good idea of what they are talking about, rather than trying to impress all others with their textbook knowledge.

I notice that those who felt that they knew the answer before failed to answer. Let me guess, they didn''t see my last post! Surprise, surprise.

My opinion is: that cyber-chick is hot!

Oh programming-wise, ahh I say #2 (although I believe #1 is faster)...

www.cppnow.com

This topic is closed to new replies.

Advertisement