I am trying to use a struct of one class in another class. My first class looks like this:
Class1.h
#ifndef CLASS1_H
#define CLASS1_H
class Class1
{
public:
Class1();
~Class1();
struct St{
int x;
}
St struct1;
private:
};
#endif
Now in the header of the second class, I want to use this struct and variable.
Class2.h
#ifndef CLASS2_H
#define CLASS2_H
#include "Class1.h"
class Class2
{
public:
Class2();
~Class2();
St struct2;
private:
};
However, it says:
identifier "St" is undefined.
When I use it this way:
Class1::St struct1;
the error goes away. What are the issues with my code?