I have a struct that I want to fill out in a separate source file from where I am running main. In the header file I included the extern but when I go to define the variable in a source file it doesn't work.
//This is a header file
struct example {
int data1;
float data2;
bool example;
}
extern example tmp;
And then in a source file:
example *tmp = new example;
I'm getting the error " Expected unqualified-id
". Why is that?
example
vs example*
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.