C++ Incomplete Type Is Not Allowed On Extern Void, / Structure, C Language

So, I have been lately trying to implement a* algorithm in my code to do this challenge but as you can see in my code (I just copy-pasted my code till the point I get the error) there's an error that says:

6 IntelliSense: incomplete type is not allowedc:UsersJuanshiDocumentsVisual Studio 2013ProjectsProject6Project6
ode.h12Well, thanks!

*

struct Node { Vector2 position; int G, H, F; Node parent;A class or struct cannot contain an instance of its own type – you want a pointer.

Đang xem: C++ incomplete type is not allowed

Do you know what could I use instead of a Node* in my case?

What happens is that in here:

std::list openList;std::list closedList;startNode.calc(map, endPos);openList.push_back(startNode);while (!openList.empty()){auto min = std::min_element(openList.begin(), openList.end());auto current = Node(*min);current.calc(map, endPos);closedList.push_back(current);openList.remove(current);I'm making current to be equal to the minimal element in openList.

And later in the code

if (inOpen == openList.end()){successor.calc(map, endPos);successor.parent = ¤t;openList.push_back(successor);}I'm setting the address of current to be successor's parent.

What happens, is that in the next iteration, it seems that current is defined in the same address, successor's parent will be equal to the new current.

Read more: How To Make A Spellbook In Minecraft, Magic Spell Book!

What should I use instead of a Node*, because that seems to be what's making my code not work.

1
Share
ReportSave
Continue this thread 

level 1
5 years ago
A class can't contain itself. To understand why this is, try to write out what the memory would look like for a single instance.

Read more: Recipe: Potion Of The Old War Rank 3, Potion Of The Old War

1
Share
ReportSave
level 2
5 years ago

It's turtles all the way down!

1
Share
ReportSave
level 2
Original Poster5 years ago

I've never written anything in memory out. How do I write in paper something that's in memory?

1
Share
ReportSave
Continue this thread 

View Entire Discussion (12 Comments)
More posts from the learnprogramming community
Continue browsing in r/learnprogramming
r/learnprogramming
A subwtbblue.com for all questions related to programming in any language.
2.2m
Members

2.4k

Online

Created Sep 24, 2009
Join

*
*
*
*

*

Top posts june 23rd 2015Top posts of june, 2015Top posts 2015
helpwtbblue.com Appwtbblue.com coinswtbblue.com premiumwtbblue.com gifts
aboutcareerspressadvertiseblogTermsContent policyPrivacy policyMod policy
Back to Top

Leave a Comment