Under Linux compiles C ++ class drop

xiaoxiao2021-03-06  17

Recently, I have learned under Linux, although there is no difference in C / C programming under Linux, but some subtots are also worth noting, such as when compiling a C program, I followed Windows. The mode is compiled, but I can't compile success. I finally look for information, I understand the reason and suddenly open.

When compiling C files under Linux, the call of the header file is not as Wondows, such as for example:

The project contains 3 files: hello.h hello.cpp mypro.cpp

/*file://hello.h*/

#ifndef _hello_h_

#define _hello_h_

Class Hello

{

Hello;

Void Display ();

}

/*file://hello.cpp*/

#include "hello.h"

Hello :: Hello ()

{

}

Hello :: diaplay ()

{

COUT << "Hell!" << endl;

}

/*file://mypro.cpp*/

#include "hello.h"

int main ()

{

...............

...............

}

Under Windows, this program is compiled without any errors, but it will be wrong under Linux. Where is the error? Is on the call of the header file

The header file that is transferred to the class under Linux is a file called * .cpp, not the * .h file.

转载请注明原文地址:https://www.9cbs.com/read-41570.html

New Post(0)