Click here to Skip to main content
15,909,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: selam Pin
Florin Crişan7-Jan-08 1:48
Florin Crişan7-Jan-08 1:48 
QuestionMessage handled in the parent class (the one inherited from) without redirectioning it manually? Pin
Joan M5-Jan-08 1:30
professionalJoan M5-Jan-08 1:30 
AnswerRe: Message handled in the parent class (the one inherited from) without redirectioning it manually? Pin
CPallini5-Jan-08 2:29
mveCPallini5-Jan-08 2:29 
GeneralRe: Message handled in the parent class (the one inherited from) without redirectioning it manually? Pin
Joan M5-Jan-08 5:06
professionalJoan M5-Jan-08 5:06 
Generalbad_alloc Pin
George_George4-Jan-08 23:08
George_George4-Jan-08 23:08 
GeneralRe: bad_alloc Pin
CPallini5-Jan-08 0:19
mveCPallini5-Jan-08 0:19 
GeneralRe: bad_alloc Pin
George_George5-Jan-08 2:32
George_George5-Jan-08 2:32 
GeneralRe: bad_alloc Pin
CPallini5-Jan-08 4:06
mveCPallini5-Jan-08 4:06 
George_George wrote:
It seems bad_alloc only occurs when there is no memory or not enough memory (as showed in the sample).

Maybe, see the following lines.



George_George wrote:
And we can not input invalid value, like -1, compiler will fail. Do you agree with me?



Well, a negative integer is casted to a size_t one, that is an unsigned one, since -1 turns out to a very big unsigned value (4294967295), the compiler is able to detect the error. But a silly trick like the following
int *p;
int a=1;
int b=rand()> RAND_MAX / 2 ? 1 : 2;
try {
  p= new int[-a*b];
}
catch(...)
{
  printf("Exception, George!\n");
}

makes the compiler happy but an the exception is thrown at run-time.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: bad_alloc Pin
George_George5-Jan-08 4:20
George_George5-Jan-08 4:20 
QuestionRe: bad_alloc Pin
Hamid_RT5-Jan-08 18:07
Hamid_RT5-Jan-08 18:07 
GeneralRe: bad_alloc Pin
George_George6-Jan-08 2:30
George_George6-Jan-08 2:30 
GeneralRe: bad_alloc Pin
Hamid_RT6-Jan-08 5:16
Hamid_RT6-Jan-08 5:16 
GeneralRe: bad_alloc Pin
George_George6-Jan-08 20:43
George_George6-Jan-08 20:43 
GeneralRe: bad_alloc Pin
Hamid_RT6-Jan-08 21:10
Hamid_RT6-Jan-08 21:10 
GeneralRe: bad_alloc Pin
George_George6-Jan-08 21:15
George_George6-Jan-08 21:15 
GeneralRe: bad_alloc Pin
Hamid_RT7-Jan-08 5:26
Hamid_RT7-Jan-08 5:26 
Questionhow to set inlude of option? Pin
gentleguy4-Jan-08 22:36
gentleguy4-Jan-08 22:36 
AnswerRe: how to set inlude of option? Pin
toxcct4-Jan-08 23:36
toxcct4-Jan-08 23:36 
GeneralOff-topic Pin
CPallini5-Jan-08 0:15
mveCPallini5-Jan-08 0:15 
GeneralRe: Off-topic Pin
toxcct5-Jan-08 7:25
toxcct5-Jan-08 7:25 
AnswerRe: how to set inlude of option? Pin
CPallini5-Jan-08 0:11
mveCPallini5-Jan-08 0:11 
GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:17
gentleguy5-Jan-08 1:17 
GeneralRe: how to set inlude of option? Pin
CPallini5-Jan-08 1:30
mveCPallini5-Jan-08 1:30 
GeneralRe: how to set inlude of option? Pin
gentleguy5-Jan-08 1:39
gentleguy5-Jan-08 1:39 
GeneralRe: how to set inlude of option? Pin
CPallini5-Jan-08 4:22
mveCPallini5-Jan-08 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.