- #1
Linda8888
- 7
- 1
- TL;DR Summary
- Is it because both the variables of MyStruct in HisStruct.h and HerStruct.h, and the variable of int in MyStruct.h have the same name: 'a'
C:
[B]// MyStruct.h[/B]
typedef struct {
int a;
float b;
char c;
} MyStruct;[B]// HisStruct.h[/B]
#include "MyStruct.h"
typedef struct {
MyStruct a;
int b;
} HisStruct;[B]// HerStruct.h[/B]
#include "MyStruct.h"
typedef struct {
MyStruct a;
float b;
} HerStruct;[B]// main.c[/B]
#include "HisStruct.h"
#include "HerStruct.h"
int main() {
HisStruct foo;
HerStruct bar;
foo.a.a = 1;
bar.a.a = 2;
return 0;
}
[Code tags inserted by a Mentor]
Last edited by a moderator: