Originally Posted by JogaBonito1502
I have an update on this issue. Instead of using a class within another class, I'm trying to create a dynamic array using new/delete in a class function. However, I keep getting this incomplete type error. Am I supposed to declare the dynamic array in the header file definitions? I currently have it in the actual code for the function (which is located in the source file). The class definition header file is included in the source file. Do I need to make a second declaration of the form:
before int main() in my source file? By that I mean with all my #include's.
It's was a bit difficult following exactly what you were explaining so I'll try to answer what I think
In your header file you want to have a pointer
declaration (unless of course it is only to be accessed by one particular function then you don't have to have it in your header). That is, if you want to create a dynamic array of ints use this:
Then in your implementation file for the function you create a new array by using (for example):
which creates a dynamic array of size 10.
Ok, you probably already knew that but just making sure.
You only need to include (assuming in this case your header file is called A.h):
Then in your main() create a new object using:
to access your class members and functions.
edit - k, after reading again I don't think I answered any of your questions lol