Home > Back-end >  Using a extern reference structure variables, why not give it to the assignment??? Have a great god
Using a extern reference structure variables, why not give it to the assignment??? Have a great god

Time:09-19

Initsetting. H file

# # ifndef INTISETTING_H_
# define INTISETTING_H_
#include
#include
Struct Position
{
Double E;
Double N;
Double U;
};

Struct init
{
Int num.
STD: : string filename;
The Position truePosition;
};

//extern init Settings;
//extern void disp (const init & amp; Settings);

# endif

.cpp file
# include "intisetting. H"

Init Settings={500, "GPS_SDR. Bin," {123.3, 456.6, 789.9}};

Void disp (const init & amp; Settings)
{
STD: : cout}

. The main file
#include
#include
# include "intisetting. H"
using namespace std;
//extern init Settings;
//extern void disp (const init & amp; Settings);

Int main ()
{
Disp (Settings);
//Settings={12, "SanGuo. TXT", {132.4, 465.7, 798.2}};//???????
Settings. Num=12;
Settings. The filename="SanGuo. TXT";
Settings. TruePosition. E=132.4;
Settings. TruePosition. N=465.7;
Settings. TruePosition. U=798.2;
Disp (Settings);
return 0;
}

Question://Settings={12, "SanGuo. TXT", {132.4, 465.7, 798.2}};//??????? Back to the setting value assignment will appear error: expected an expression

CodePudding user response:

Init Settings={500, "GPS_SDR. Bin," {123.3, 456.6, 789.9}};
The syntax structure of the variable is initialized, general assignment I'm afraid not,

CodePudding user response:

One by one ~ ~ ~

CodePudding user response:

reference 1st floor u010165006 response:
init Settings={500, "GPS_SDR. Bin," {123.3, 456.6, 789.9}};
The syntax structure of the variable is initialized, I'm afraid not, general assignment

Right, the grammar, only when you declare a variable to such use, the statement later, you can only use ordinary method to access:

Settings. Num=12;
Settings. The filename="SanGuo. TXT"
.
  • Related