How to explain the following code?

I have two questions about C ++ programming.

1) int a[10] = new int*;is this statement valid?

2) extern void test(int a,int b) throw(const char *, RangeErr);

what does test () do, throw (const char *, RangeErr) means throw two exceptions? and what is RangeErr? and why extern? what does this function do?

+3
source share
4 answers

1) Not valid. An array is not a pointer (although it can be implicitly converted to one in some contexts). Try instead:

int* a = new int[10];

2) ( ). , " ", , . , "".

throw , ( C- RangeErr, , , , ). - , std:: (), . , , , , , ++ 11 .

+5
  • . . , .

  • , , , . throw , , C RangeErr, . RangeErr . extern , .

throw . , throw () , , . . " " Herb Sutter, - ++.

+2

1) . .

2) test() - . throw(...) , . RangeErr - . extern , (.. ).

+1

1), No

2), , "const char *" "RangeErr". , RangeErr , , , , . , (dll, - ), api , , . ^^ , .

+1

All Articles