2018-09-16 16:17:19

trying to look at c++, and i'm wondering how exactly i program that i've codi=ed in c++, do i put it in a txt and run it with the c++ compiler thing.

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2018-09-16 16:41:55

greetings. You should save it as a cpp file and then import it in to the ide you're using. For me, it's codeblocks, so i open up the file and build it. If there are no errors i either use the run command or compile it. I still haven't tried other ides like VS, but in codeblocks if you have your project opened and you make a change to it using your text editor, it prompts you weather you want to reload the file or not.
Regards

2018-09-16 17:06:18 (edited by Kyleman123 2018-09-16 17:09:07)

We would need more info to help you with the specific commands. but the general idea is:
1. right your main function preferably in a main.cpp file. if this is a simple program this might be all you need.
2. write your class implementations  in separate cpp files e.g. ClassName.cpp.
3. make header files that declare your classes: ClassName.h.
4. #include your header files where ever they are needed.
5. if you are using an IDE, xCode or Visual studio are recommended, when you press compile or run it will take care of all of the compiling and linking for you. if yo are using a CL compiler, you will need to compile and link things yourself.

if you just have a main.cpp and no errors
g++ main.cpp
should give you a working program in a terminal.
note: the compiled program is probably called a.out, you can also provide more args to g++ and specify a name if you wish.

I don’t believe in fighting unnecessarily.  But if something is worth fighting for, then its always a fight worth winning.
check me out on Twitter and on GitHub