Reputation: 61
I have been using Turbo C++ for 1 year now, thing is... i know it's extremely old, but now i have got used to it's syntax.Can you suggest a (better) IDE which doesn't show any error with turbo C++ code?
I have tried visual C++ and codeblocks, and even tried (really wildly) an eclipse CDK pack. But, all of them show errors to a normal programme like:
#include<iostream.h>
void main()
{cout<<"hello";}
Upvotes: 3
Views: 1742
Reputation: 88155
The problem with Turbo C++ being so old is that it is much less conformant than modern compilers. Ages ago C++ compilers all varied wildly; supporting different features, different syntaxes, and had severe bugs in their C++ implementations. Back then writing portable C++ was difficult. Things have vastly improved over the last 15 years as compilers matured with got better and better about implementing the common C++ standard.
So probably the major benefit of modern compilers is that they are more conformant; that they don't support the same wrong dialect of C++ that Turbo C++ supported.
Instead of asking for a modern C++ compiler that doesn't have the major feature that makes modern compilers desirable, you should simply figure out the areas of Turbo C++'s dialect which are not correct. This is probably a good exercise anyway; C++ programmers learn a fair bit of C++ from their compiler, and so when the compiler is wrong they learn wrong things. Using different compilers helps ferret out such misunderstandings and improves one's knowledge of C++. It shouldn't be too hard to make the adjustments.
So here's what's wrong with the simple program you posted as far as the authoritative ISO specification for C++: Standard C++ headers don't have '.h' suffixes on them, so instead of #include <iostream.h>
you must use #include <iostream>
. These standard headers put things in namespaces, so in order to access cout
you have to access it inside the std
namespace: instead of cout<<"hello";
you should write std::cout << "Hello\n";
. Finally main
is required to return int
rather than void
, so your whole program might look like:
#include<iostream>
int main() {
std::cout << "Hello\n";
}
Upvotes: 4
Reputation: 51840
It doesn't matter if you've got used to that syntax or not. If you want to write C++ code, you have to use C++ syntax. Just like you can't suddenly drive on the left side of the road in Germany just because you got used to that side in England. If you want to drive in Germany, you have to follow the rules. If you don't, you gonna crash.
Using a modern C++ compiler means you have to write standards-conforming C++ code.
Upvotes: 2
Reputation: 96241
That's actually not a normal C++ program.
main
always returns int
and <iostream.h>
has been technically unavailable for years (in favor of <iostream>
, although many compilers supported for some length of time).
Instead of trying to find a GUI that accepts your existing code, I would try to get a book and learn/review a more recent C++ (at least C++03) and then use a modern compiler (g++ or the free Visual Studio one) to build your standard code.
Upvotes: 1