Why does my c++ compiler seem to be compiling in c -


i using geany (code::blocks wouldnt run programs) compiler compile simple c++ program 1 class. on linux mint 17 on dell vostro 1500. compiling works fine both .cpp files, header file gives error:

gcc -wall "morgan.h" (in directory: /home/luke/documents/coding/intro#2) morgan.h:5:1: error: unknown type name ‘class’ class morgan ^ morgan.h:6:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token { ^ compilation failed. 

this main.cpp :

#include <iostream> #include "morgan.h" using namespace std;  int main() {     morgan morgobject;     morgobject.saystuff();     return 0; } 

this header file (morgan.h):

#ifndef morgan_h #define morgan_h   class morgan {     public:         morgan();         void saystuff();     protected:     private: };  #endif // morgan_h 

and class (morgan.cpp):

#include <iostream> #include "morgan.h" using namespace std;  morgan::morgan() { }  void morgan::saystuff(){     cout << "blah blah blah" << endl; } 

i not know going wrong, appreciated. copy , pasted same code windows compiler , worked fine, might linux.

also when run main.cpp shows: "./geany_run_script.sh: 5: ./geany_run_script.sh: ./main: not found"

your issue compiling c++ code c compiler (gcc). command looking g++. complete command compile code is:

g++ -wall -o run.me main.cpp morgan.cpp

if file included (in case morgan.h file, not need explicitly compile it. )


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -