c++ header file "a.h" :
#pragma once
#include "b.h"
struct A {
void f() {
b.f();
}
B b;
int i;
};
c++ header file "b.h" :
#pragma once
#include"a.h"
struct B {
void f() {
int x = a->i; //error occur
}
A* a;
};
"test.cpp":
#include "a.h"
int main(){
A a;
a.f();
}
Call 'a->i' in B will trigger error.Why?How to solve it.
Aucun commentaire:
Enregistrer un commentaire