Search code examples
c++linkervisual-studio-2019header-files

Can I split my code into header and cpp files at the end of development?


I am coding a minesweeper game and I am currently splitting declarations and code between header and cpp files like you're supposed to, however, this is making it kind of convoluted to keep track of everything.

I know this is against best practices, but could I just declare and code everything on cpp files and then split them up into their respective files at the end? Would this mess up anything inside Visual Studio 2019? I feel like it shouldnt but ive had linker problems with VS code in the past and I havent been able to fix them (one of the reasons why I use visual studio for cpp now) so I just want to make sure before I do something thats going to bite me later on.

Any insight is appreciated. I know its a lazy way to cope with the problem but Im just trying to get this done quickly.


Solution

  • Declaring and coding everything on cpp files will cause error lnk2005. Putting it all in the header file won't cause the error, although this is also against best practices. But it all depends on personal writing style.In addition, code should be easier for others to read and understand. And It's a good choice to follow experienced people's coding style.