-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template/Generic Compilation #51
Comments
I figured out that putting all of the function definitions in the header fixed the issue. I'm still not quite sure why it's necessary, but it's a better solution than needing to define every variant of the class in extra.cpp. |
I had answered this in a different issue. #14. Here is what I found:
chatGPT says: https://chatgpt.com/share/66f9d97d-481c-800a-9372-c31f27465483 Here is what I wrote before I aske chatGPT, but I haven't really used templates in c++ (i do use them in typescript): If you show me the code (commit it, or provide a link, or whatever), i can take a look. |
i sent you an email with an intro to don, who can explain this in detail. |
please close this if you think its fixed. |
I mentioned this over the phone, however, I found a temporary solution and would like some input on why it was necessary.
The problem stems from a generic LinkedList implementation I made:
When this was implemented in pong-menu.h and pong-menu.cpp (where it was used), everything worked fine. However, when I was setting up a new class for rendering centered text I moved it to extra.h and extra.cpp so it could be used among multiple files. When I did this, I started getting the following linking errors:
I found that moving the MenuButton struct into extra.h and adding:
to extra.cpp fixed it.
I was wondering if you knew what might be causing the explicit declaration to be necessary and if there's any other way I could fix this?
The text was updated successfully, but these errors were encountered: