Having some very weird problems with class constructors and also with copying code between files [closed]

  c++, corruption, default-constructor

Edit: for some reason if I make the default constructor a void function the red lines disappear; but why on earth do I now have to make a default or parameterised constructor a void function whereas until this morning all I’ve had to do is declare them in the header as I’ve written in this code and define them in the implementation, also as in this code?

Here’s the code:
https://www.twitlonger.com/show/n_1srrg2j?new_post=true

I’ve been working on classes for a week solid and all of a sudden
they’re not working. I try to make a default constructor and just get a red line underneath and a bunch of errors when I try to compile saying:

Severity Code Description Project File Line Suppression State
Error (active) E0260 explicit type is missing (‘int’ assumed) warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Header.h 8

Error C4430 missing type specifier – int assumed. Note: C++ does not support default-int warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Header.h 8

Warning C4183 ‘temp_c’: missing return type; assumed to be a member function returning ‘int’ warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Header.h 8

Error C4430 missing type specifier – int assumed. Note: C++ does not support default-int warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Source.cpp 5

Error C4430 missing type specifier – int assumed. Note: C++ does not support default-int warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Header.h 8

Warning C4183 ‘temp_c’: missing return type; assumed to be a member function returning ‘int’ warp 4 C:UsersUserDesktopsaved cpp fileswarp 4Header.h 8

I reckon my computer is broken–unless the fault is Visual Studio’s which I doubt in this case–because I don’t think there’s anything wrong with the code and there seems to be some nonsense going on whereby thus: I make an error in a file, I correct the error, I copy that corrected code to another file, I then get an error in that new file saying ‘external error line 1’ or something like that (hard to replicate the scenario because it doesn’t always happen); so I think what happens is that the original error ‘breaks’ the line of the file it’s written on and then anything
else written on that ‘broken’ line is by default broken, and also is broken any line onto which I copy code first written on the originally broken line. If I’m right about this then I can’t tell you how absurdly frustrating this is to have to contend with whilst first learning to code and whoever the rat is who sold me this ‘refurbished! good as new!’ computer on Ebay has a stinking hell of a karmic debt to pay.

But in this particular case I made all this code afresh in a new project without copying anything in so I reckon my computer is just dog-poop garbage-fire fuel.

But maybe the code is incorrect, maybe I have to at least fill the parameters of a default class constructor with SOMETHING and not leave it blank; but no because doing so doesn’t even change the error.

Also, there is a buffer time window that has to elapse after closing a VS project before I can rename, move, or copy it; if I try to do so without waiting the project corrupts.

Source: Windows Questions C++

LEAVE A COMMENT