Template and abnormal problems
Seeing this problem on 9CBS (text is http://community.9cbs.net/expert/topic/3565/3565571.xml?temp =.4035608):
There is a code as follows, help fill in 5 space ~~~~~~ 01 #include
53 b1 = a1 [-5] [10]; // has a proceedment prompt: row down the border [-5] 54 b1 = a1 [10] [15]; // has a proceedment note: liner crosions [10] 55 b1 = a1 [1] [4]; // No offshore prompt 56 b2 = a2 [2] [6]; // There is a proceed tip: column subscripts [6] 57 b2 = A2 [10] [20] ; // has a proceedment prompt; the sumbure crosenal [10] list the bid-offline [20] 58 b2 = a2 [1] [4]; // No Crossing Tip 59} After reading the topic, this test template use and Abnormal capture topic.
Sketchy, here there are 2 type templates, one is Template From the top down, obviously the template ArrayBody is a member of Array (line 38), and Array may have to access the members of ArrayBody (not affirmation). Temporarily speculate that the Friend of the first nine 5 behavior is Array The second empty (line 9) TPBODY is a pointer, give me the initial impression that what should be new, or what is pointing. It is still not sure, first empty. Look at the third empty, there is a catch (char), obviously 23 lines should be throw ('e'), of course, is not necessarily 'E', as long as it is a char. The fourth empty is still not known, the fifth space is definitely arraybody (IRSZ, ICSZ). why? Because this is obviously to construct a class (or template) before constructing Array, and Array member template (or class) is only arraybody, it should be yes. The simulation here is a two-dimensional array. Look at 49 lines array The same is the same as the 50th line of code. By 53 lines, B1 = A1 [-5] [10]; first execute ArrayBody Ok, slow, returntrow * icolumns j] is a one-dimensional array, the second empty New T [IRSZ] [ICSZ] should be NEW T [IRSZ * ICSZ]. In this way, even the guess is filled. But you can't guarantee its correctness. It is necessary to verify it now. Take 54 lines B1 = A1 [10] [15]; 1. First execute ArrayBody 2. Only T & Operator [] (Int J), A.TBody.j should be 15. Due to the value of A.TBODY.ICURRENTROW is equal to the maximum number of rows allow (IROWS == 10, A.TBODY.ICURRENTROW can only be 9), so row_error == true, column_ error == false, Capture exceptions, thus row the crosions. Just as programs prompts. So you should think that this answer is correct. The above is a personal point of view, and the mistakes respect the advice! ^ _ ^