+ 1

Another question about classes and headers. Is this possible?

Hi all. I have been writing a practice "board game" in c++ which is only in text format as I still haven't cracked graphics (grrr). But really it is just so I can get an understanding of language structure and variable manipulation. Now the text bit is almost completed, I have loads of code in my main.cpp. I have each individual part of the game as a function which is called. Is it possible to move each of theae functions into a new cpp file with copy and paste?

17th Aug 2017, 11:52 AM
Richard Appleton
Richard Appleton - avatar
4 Antworten
+ 3
hi:) you should copy your function to .cpp file and declare them in .hpp file . in file.hpp: void f(int a);
17th Aug 2017, 12:19 PM
Hossein Najafi
Hossein Najafi - avatar
+ 2
thats better somehow you use namespaces for a bunch of functions. like std.
17th Aug 2017, 12:21 PM
Hossein Najafi
Hossein Najafi - avatar
+ 2
Thank you. Didn't want to just move it all round and wreck it.
17th Aug 2017, 12:21 PM
Richard Appleton
Richard Appleton - avatar
+ 1
If I do, does that make them classes? Will I need to create headers with constructors and destructors? Thank you?
17th Aug 2017, 11:53 AM
Richard Appleton
Richard Appleton - avatar