Reputation: 11
I am working on a programming project for an assignment. I have a class and I have to make it an ADT so I have to split the program into the interface, implementation and main project. This means I'll have 3 files. I am using codeblocks 16.01 and I tried solving the problem by downloading the codeblocks v20.03 but it did not work. My program works fine in one file but when I split it into 3 files, I get two errors:
I have read almost all the threads and tried practically everything I've read from simply closing and reopening the program to going to Settings>Compiler>Linker Settings but that did not work. Some suggested on threads that the program is not a console so I should create it as a console and I did that too but nothing worked. In fact I just create empty class and save it as main.cpp then I go to create a new class, I name my new class and uncheck "Has virtual Destructor" and I also uncheck "Virtual Destructor". I make the directory the same folder as my main.cpp and then I copy the header file to the main.cpp program try building it then I get the errors. I don't do any coding yet I'm receiving these errors.
If you can, please help by providing direct instructions because I did read a lot of threads and tried fixing this but none has worked for me
Thank you.
Upvotes: 0
Views: 174
Reputation: 11
The error in my initial post appears when you create multiple files incorrectly. The way multiple files are supposed to be created is as follows; or to fix the error, follow these simple steps:
You're first to go to create a project of type Console Application. Once that's done, you won't have any files open, you'll just see the name of your Console Application at the top.
Next, go to create a class. Once you've done that and have named your class, you'll be asked if you want to add it to your current project. You should select the yes button to add it to your current project. You will then have a .h and .cpp file.
Your main.cpp file by this point will have already been created for you. Simply go to open and find your project folder. In that folder you'll find your class files and main.cpp files. Open the main.cpp file. If you're asked to add it to your current project, click the yes button and you're good to go!
Upvotes: 1