I'm attempting to create a function called Greetings, where I put it in a separate file. I followed a tutorial on youtube, but it kept giving me errors. Below is the source code for the main.cc, Greetings.cc, and Greetings.h. Though when I tried compiling it through my Mac's terminal it ran quite fine, but when I tried running it inside my text editor (Sublime Text 3), it keeps on giving me these weird errors, long ones. Does anyone see anything wrong?
Alright so in order to use printf, I use #include <cstdio>, which is a C++ language, and in order to use cout, I use #include <iostream>, which is a C language?
Also, made the correction based off of your feedback. It still gave me errors. Here they are.
Undefined symbols for architecture x86_64:
"Greetings::Greetings()", referenced from:
_main in main-e356ad.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Finished in 3.4s with exit code 1]
[shell_cmd: g++ "/Users/conrados/Desktop/C++ Programs/Greetings/main.cc" -o "/Users/conrados/Desktop/C++ Programs/Greetings/main" && "/Users/conrados/Desktop/C++ Programs/Greetings/main"]
[dir: /Users/conrados/Desktop/C++ Programs/Greetings]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
I suggest you google, at least, the following terms and then come back here if something is still unclear: iostream, cstdio, printf, std::cout, "differences between C and C++"
Re your error messages make sure (a) all your files are in the same folder, and (b) command line is run from that folder - at least that's how it works in Windows. I just re-tried with the following: g++ -Wall -o test implement.cpp main.cpp
i.e. running the complier (g++) with all common warnings on (-Wall) to create an executable (test) using two source files (implement.cpp, main.cpp) and at the next command prompt typing in
test
i.e. the name of the executable file gave desired output