Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turbo C++ and Code blocks

Why should I use namespaces and int main in Code blocks while there are no namespaces in turbo c++ and I can use void main without returning any value as I learnt in schools. Is the compiler different, Is the C++ version different?

like image 243
Nikhil Em Avatar asked Jul 05 '14 12:07

Nikhil Em


People also ask

Which is better Turbo C or Code::Blocks?

yes, Code Blocks is the better environment to work instead of Turbo C and C++.

Can I use Code::Blocks for C?

CodeBlocks is an open-source, cross-platform (Windows, Linux, MacOS), and free C/C++ IDE . It supports many compilers, such as GNU GCC (MinGW and Cygwin) and MS Visual C++.

Is Code::Blocks good for C and C++?

Overall: It's great for learning how to code and practicing both coding and debugging. Pros: Code::Blocks is free and very easy to use. It can be used to write, compile. and debug software in the C/C++ programming languages and is very beginner-friendly.


1 Answers

First of all, Turbo C++ is a compiler bundled with an IDE targetting MS-Windows. Code Block is an IDE supporting several compilers and platforms. That is the main difference between these two tools, so you are not comparing exactly the same things.

Secondly, int is the standard return value for main, which is also standard by convention in C and C++ for program source code entry points (1). C++ compilers operating in standard mode expect programs to be written that way, so your programs should conform these expectations, if you want to use conforming C++ compilers, which are what Code Block is supporting by default. However, I'm pretty sure that you code configure Code Block to use a specific compiler in a non compliant mode (or simply a non compliant compiler), since it is a flexible IDE; you might well be able to set it up to use Turbo C++, and thus make it compile non ANSI C++. That said, I don't think that Turbo C++ does not support ANSI C++.

Thirdly, Namespaces are a feature of C++, that you have to use if you want to use the standard C++ library, but nothing forces you to otherwise.


(1) the name is a convention, but the function itself is obviously necessary.

like image 109
didierc Avatar answered Sep 30 '22 16:09

didierc