Home > Back-end >  This error is how to return a responsibility?
This error is how to return a responsibility?

Time:11-26

I wrote this code, why is wrong?
 
Template
The class node_map {
Private:
The node node_m [num] [num] {node ()};
Bool have_touch [num] [num] {false};
Public:
If # 1
Void show_all ()
{
for(int i=0; i{
for(int j=0; jCoutCout}
}//test
# endif
Void set_all ()
{
The static default_random_engine DE;
The static uniform_int_distribution & lt; Unsigned int> U (0, num - 1);
Int bomb_num;
The switch (num)
{
Case 10:
Bomb_num=15;
break;
Case 20:
Bomb_num=40;
break;
A case of 30:
Bomb_num=70;
break;
}
While (bomb_num!=0)
{
F:
Int p=u (DE);
Int q=u (DE);
If (node_m [p] [q] have_bomb)
Goto f;
Node_m [p] [q] have_bomb=true;
Node_m [p] [q] around_num=0;
- bomb_num;
}
Node_m [0] [0]. Around_num=(node_m [1] [0]. Have_bomb? 1-0)
+ (node_m [0] [1]. The have_bomb? (1-0) + node_m [1] [1].
Have_bomb? 1-0);
Node_m [0] [num 1] around_num=(node_m [0] [2] num -.
Have_bomb? (1-0) + node_m [1] [num 1] have_bomb? 1-0)
+ (node_m [1] [2] num - have_bomb? 1-0);
Node_m [num - 1]. [0] around_num=(node_m [2] num - [0].
Have_bomb? (1-0) + node_m [num 1] [1]. The have_bomb? 1-0) +
(node_m [2] num - [1]. The have_bomb? 1-0);
Node_m [num 1] [num 1] around_num=(node_m [2] num -
[num 1] have_bomb? 1-0) + (node_m [num 1] [2] num -.
Have_bomb? (1-0) + node_m [2] num - [2] num - have_bomb? 1-0);
for(int i=1; i<=num - 2; + + I)
{
Node_m [0] [I] around_num=(node_m [0] [I - 1].
Have_bomb? (1-0) + node_m [1] [I - 1]. Have_bomb? 1-0) +
(node_m [1] [I] have_bomb? (1-0) + node_m [1] [I + 1].
Have_bomb? (1-0) + node_m [0] [I + 1] have_bomb? 1-0);
Node_m [I] [0]. Around_num=(node_m [0] [I - 1].
Have_bomb? (1-0) + node_m [1]. [I - 1] have_bomb? 1-0) +
(node_m [1]. [I] have_bomb? (1-0) + node_m [I + 1] [1].
Have_bomb? (1-0) + node_m [0]. [I + 1] have_bomb? 1-0);
Node_m [num 1] [I] around_num=(node_m [num 1] [I - 1].
Have_bomb? (1-0) + node_m [2] num - [I - 1]. Have_bomb? 1:
0) + (node_m [2] num - [I] have_bomb? (1-0) + node_m [
Num - 2] [I + 1] have_bomb? (1-0) + node_m [num 1] [I + 1].
Have_bomb? 1-0);
Node_m [num - 1]. [I] around_num=(node_m [I - 1] [num - 1].
Have_bomb? (1-0) + node_m [I - 1] [2] num - have_bomb? 1:
0) + (node_m [I] [2] num - have_bomb? (1-0) + node_m [
I + 1] [2] num -. Have_bomb? (1-0) + node_m [I + 1] [num - 1].
Have_bomb? 1-0);
}
for(int i=1; i<=num - 2; + + I)
For (int j=1; j<=num - 2; + + j)
Node_m [I] [j]. Journal of around_num=(node_m [j]. [I - 1]
Have_bomb? (1-0) + node_m [I - 1] [j - 1] have_bomb
? (1-0) + node_m [j - 1]. [I] have_bomb? + (1-0)
Node_m [I + 1] [j - 1] have_bomb? (1-0) + node_m [
I + 1] [j]. Journal of have_bomb? (1-0) + node_m [I + 1] [j + 1).
Have_bomb? (1-0) + node_m [I] [j + 1] have_bomb? 1
: 0) + (node_m [I - 1] [j - 1] have_bomb? 1-0);
}
};
Int main ()
{
Node_map & lt; 10 & gt; n;
Try {
N.s et_all ();
N.s how_all ();
} the catch (exception& E) {
Cout<& lt;" Error!" }
return 0;
}//test code

Error:
E: \ \ VS_2019_C private information + + small game development \ \ demining stand-alone version. CPP In constructor 'constexpr node_map & lt; 10 ull & gt; : : node_map () ':
43 7 E: \ \ private information VS_2019_C + + small game development \ \ demining stand-alone version. CPP [Error] array must be initialized with a brace - enclosed, initializer
43 7 E: \ \ private information VS_2019_C + + small game development \ \ demining stand-alone version. CPP [Error] array must be initialized with a brace - enclosed, initializer
E: \ \ VS_2019_C private information + + small game development \ \ demining stand-alone version. CPP In function 'int main ()' :
134 15 E: \ \ private information VS_2019_C + + small game development \ \ demining stand-alone version. CPP [Note] synthesized method 'constexpr node_map & lt; 10 ull & gt; : : node_map () 'first required here
I an array of the person that should be no problem!
Look at the beginning of node_m and have_touch definition

CodePudding user response:

Error means you have no initialization,

CodePudding user response:


I can emersion the question, in adding the right header file and the using instructions, and a correct node won't appear above problems after class,

CodePudding user response:

reference 1st floor zjq9931 response:
error means you have no initialization,

I'm not have been initialized

CodePudding user response:

refer to the second floor Constructor_ response:
I can emersion the question, in adding the right header file and the using instructions, and a correct node won't appear above problems after class,

Never used, may be in the class header file initialization is in it? Not sure, don't know, sorry.
  • Related