JogaBonito1502
Guru
- Messages
- 7,841
- Location
- U.S.
USING C++
I am trying to use a class inside another class. However, when I define the variable from the first class in the second I get an error saying, "Incomplete type". This is what my code looks like.
Header file A.h
Then, I include that header file in a second header file, B.h, which defines my second class.
On my main source file I have:
Now the problem is that the array array2 gives me errors saying incomplete type. If I delete A.h and not define "variable", then "i" gives me an error with incomplete type on main(). What's wrong here?
I am trying to use a class inside another class. However, when I define the variable from the first class in the second I get an error saying, "Incomplete type". This is what my code looks like.
Header file A.h
Code:
class A
{
Private:
int rows;
int columns;
int array1[];
Public:
void build();
};
Then, I include that header file in a second header file, B.h, which defines my second class.
Code:
#include "A.h"
class B
{
Private:
int m;
int array2[];
A variable;
Public:
void test();
};
On my main source file I have:
Code:
#include "A.h"
#include "B.h"
#include <iostream>
using namespace std;
int main()
{
int i[];
//random stuff here
return 0;
}
Now the problem is that the array array2 gives me errors saying incomplete type. If I delete A.h and not define "variable", then "i" gives me an error with incomplete type on main(). What's wrong here?