Can cc compile a .cpp file?

0

I am new to using a Linux environment to compile and run my programs in c and c ++. As such I have realized that to compile files.c in terminal I occupy cc or gcc , otherwise with .cpp files that occupy g ++

My doubt was that if there was any way to compile a file.cpp using cc inside the console?

    
asked by Fernando Gonzalez 12.06.2018 в 21:39
source

1 answer

0

In this case, the important thing is not the extension but the content of the file.

A C compiler will only be able to compile C compatible code, while to compile C ++ code you will need a C ++ compiler.

The extensions are not limiting and, for example, nothing prevents you from creating a prueba.c file that contains a complete program written in ADA ... it is not a good practice but it can be done.

The fact is that you have to look at the content you want to process. If this content is C ++ you will have to use a C ++ compiler, while if the source code is C you can perfectly use a C compiler.

    
answered by 13.06.2018 в 08:14