Switch from Turbo C ++ (old) to a newer similar compiler

I have been using Turbo C ++ for 1 year, this is ... I know it is very old, but now I am used to the syntax. Can you suggest a (better) IDE that doesn't show any error with turbo C ++ code? I've tried visual C ++ and codeblocks and even tried (really wildly) the eclipse CDK pack. But they all show errors for a normal program, for example:  #include<iostream.h> void main() {cout<<"hello";}

+3


source to share


3 answers


The problem with Turbo C ++ being so old is that it is much less compatible than modern compilers. C ++ compilers have varied a lot in the past year; supporting different features, different syntaxes and had serious bugs in their C ++ implementations. Writing portable C ++ was difficult back then. The situation has improved dramatically over the past 15 years as compilers matured to improve and refine the implementation of the C ++ standard standard.

Thus, perhaps the main advantage of modern compilers is that they are more compatible; that they don't support the same wrong C ++ dialect supported by Turbo C ++.

Instead of asking for a modern C ++ compiler that lacks the core feature that makes modern compilers desirable, you should simply figure out the areas of Turbo C ++ dialects that are wrong. This is probably a good exercise; C ++ programmers learn a fair bit of C ++ from their compiler, so when the compiler is wrong, they learn wrong. Using different compilers helps to identify such misunderstandings and improve one knowledge of C ++. It shouldn't be too difficult to make the settings.



So what's wrong with the simple program you posted regarding the authoritative ISO specification for C ++: The standard C ++ headers don't have the .h suffixes on them, so #include <iostream.h>

you should use instead #include <iostream>

, These standard headers put things in namespaces. so to access cout

you need to access it in the namespace std

: you cout<<"hello";

should write instead std::cout << "Hello\n";

. Finally, you main

want to return int

, not void

, so your whole program might look like this:

#include<iostream>

int main() {
    std::cout << "Hello\n";
}

      

+4


source


It doesn't matter if you are used to this syntax or not. If you want to write C ++ code, you need to use C ++ syntax. Just like you cannot suddenly drive on the left side of the road in Germany just because you are used to that side in England. If you want to travel to Germany, you must follow the rules. If you don't, you will collapse.



Using a modern C ++ compiler means you must write code that conforms to C ++ standards.

+2


source


This is actually not a normal C ++ program.

main

always returns int

, and <iostream.h>

technically not available for many years (in favor <iostream>

, although many compilers have been supported for some time).

Instead of looking for a GUI that accepts your existing code, I would try to get the book and study / review more recent C ++ (at least C ++ 03) and then use a modern compiler (g ++ or free Visual Studio) to generate standard code.

+1


source







All Articles