Trouble implementing several files in C++

I’m on the penultimate video for the C++ Programming for Blockchain Developers course and am getting different results to what Ivan is demonstrating. I wonder if I have configured something incorrectly upon installing CodeBlocks.

When I create a new class the resulting file structure is different to the demonstration, instead of getting:


I get:

image .

Note that the .h and .cpp files come with no file extensions in my case. I have tried renaming them but it doesn’t work.

I suspect that part of the problem lies in the settings form when creating the class, in Ivan’s demonstration I can make out the following:


while in my case I get:

All tick-boxes are the same higher up in the form.

I could of course change the folder destinations manually and add file extensions in the form but I can’t figure out why mine is not autofilling and structuring the files by default in the same way as the demonstration.

Any guidance towards resolving this would be much appreciated. I’d like to finish this course and get started on some real projects.

1 Like

Hey, I think this could be just because of a different view because of different versions of codeblocks. Have you tried writing the code and testing if it works? The folder structure shouldn’t concern you at this point. :slight_smile:

Hello again @Alko89 :slight_smile: thanks for your input. I have tried by just writing the code and build+running it but I just get errors. Namely the following:

It’s not a matter of a different view/version. It doesn’t generate .h and .cpp files only two files without any file type/extension. As such, #include "Car.h" doesn’t work as there is no such file. There is only a file called Car in the include folder and also Car in the src folder (Note, no file extension as described in the topic). The code in these files is not even recognised as code by the IDE as you can see below, there is no syntax highlighting or code completion available:

image image

I have since tried manually setting the file extension in the new classes set up form and that seems to work (it also produces the desired folder structure seen in the demo) but I still don’t know why this manual input is necessary while in the demo it seems to do so by default. Is there perhaps a setting I can change in Code::Blocks for these file extensions to be set by default?

Hmm, I’m not used to codeblocks. Do you have options to choose from when creating a new file? Can you post a screenshot of the new file dialog?

I seem to have fixed it by manually inputting the file extensions once for both the header file and implementation files. It is now autofilling the relevant fields correctly. The new class dialog looks like so:

For reference, the field Filename under Header file and Implementation file towards the bottom of the form were not including the relevant .h and .cpp file extensions as seen in the above screenshot. To reiterate, I got this working now by manually adding the file extensions and it is now autofilling as seen in Ivan’s demo.

Strange…this seems like a bug. Have you checked the files created in Explorer?

Yes. Initially when it wasn’t working, the files reflected in explorer with no file extension and the file was not readable by any program, only the text could be seen in the IDE without syntax highlighting. When I manually input the file extensions the folder structure was automatically correct as were the file extensions. Since doing it manually once, it does it automatically afterwards so that would seem to be the resolution to the problem.

1 Like

Interesting. Glad you were able to fix the issue. I’m not sure what happened that it didn’t work at first.

1 Like