C++ includes require the cpp (not header) file


#1

Typically in C++ classes are split into a header (.h) and a class (.cpp or .cc) file. Then, if the class is used in another source file, the header file is included. For instance:

Date class has Date.h and Date.cc file.
main.cc would use:
#include “Date.h”

to include the Date class.

However, cloud9 seems only to work if the .cc file is included. If I try to include the .h file I get an error saying the class methods are undefined. One problem with this is that the included .cc file cannot have its own main function. This also means that code imported from other IDEs must be modified.

If this is unexpected, what should I do to fix? If not unexpected, could someone please explain the reasoning for this?


#2

One limitation of Cloud9 C++ support is that it only supports single source code compilation out of the box.

If you want to be able to compile with one click, then you need to create a Makefile and create a custom runner to reference the Makefile.

Or you can compile and link from the command line.