I have some confusion with how I can use definition from one header with other. Let's say I want to use Test type in classA.cpp. Should I import test.h in the classA.cpp file or the header? Seems like forward declaration doesn't work as implemented bellow (I get incomplete type is not allowed). This leaves me concluding I have to import test.h in classA.h. Then in my main.cpp only import classA.h as otherwise I get error that _Test Test is already defined.
test.h
#ifndef test_h
#define test_h
typedef struct _Test
{
double somevalue;
} Test;
#endif
classA.h
#ifndef classA_h
#define classA_h
typedef struct _Test Test;
class classA{
public:
Test qtest;
void somefct();
};
#endif
classA.cpp
#include "test.h"
#include "classA.h"
void classA::somefct(){
qtest.somevalue;
return;
}