I have started learning C++ for my programming class. I have downloaded this \"Hello World\" program:
#include
using namespace std;
int mai
"Turbo C++" can mean numerous compilers. When asking this question, it is important to include the version number.
Borland Turbo C++ up to version 3.1 were pure MS DOS compilers in the classic blue background IDE. These were released roughly somewhere between 1989 to 1992, long before C++ had become standardized, which happened in the year 1998. And so they used a pre-standard dialect of C++.
Most notably they used the #include <iostream.h>
syntax rather than the standard #include <iostream>
, but also didn't cover a whole lot of C++ features such as namespaces, templates etc. The template library STL was not part of the standard yet, so everything related to that library was pretty different from what later became standard.
Later in the 90s, Borland released several DOS/Windows compilers with better conformance. Up to version 5 somewhere they still struggled with complete conformance to C++98, although these Windows versions were fairly close to it.
In the late 90s, they dropped the name "Turbo C++" in favour for Borland C++ Builder, which was not just an IDE but a complete RAD tool based on Delphi. These compilers were fully compliant with C++98 and later C++03.
Around 2005, Borland dropped compilers as part of their product line. The compilers became "Codegear", which later became Embarcadero. Somewhere around then, they released a free version of Borland Builder that they named "Turbo C++". This version was fully conforming to C++03.
Nowadays these compilers are called Embarcadero C++ Builder. I believe they currently support up to C++11 with some C++14. More info here.
Needless to say, as a student you should not use anything but modern compilers. Using MS DOS compilers from 1991 when learning C++ in the year 2018 is simply madness. Not only is it counter-productive, it is directly harmful and will make you a bad C++ programmer. If your school is forcing you to use Turbo C++ 3.1 or older, then your school is bad and your teachers are severely incompetent. Please link this post to them and their principal.
There's no problem with this program. (Except probably some stylistic issues —
using namespace std
is not recommended). The problem is with Turbo C++. It is a very old piece of software. It implements a dialect of C++, so-called pre-ANSI C++, that has completely fallen out of use by the beginning of this millennium. The first ANSI standard for C++ was published in 1998, then there was the 2003 version, the 2011 version, the 2014 version, the 2017 version, and now we expect the 2020 version to be officially published. Each of these standard revisions brought more or less significant changes to the language.
For Turbo C++ you have to modify the program like this:
#include <iostream.h> // note the .h suffix
// using namespace std; // Turbo C++ doesn't implement namespaces
int main()
{
cout << "Hello, World!";
return 0;
}
If you look at this program, the difference between the modern C++ dialect and the one accepted by Turbo C++ may seem small. However it will grow much larger as your programs will be getting more complex.
While you can learn programming using Turbo C++ I would strongly recommend to avoid that if humanly possible because of the following problems:
There are many modern free (as in beer, as well as in speech) compilers and IDEs you can use in place of Turbo C++. Some of these include:
Regrettably, some schools/teachers appear to force students to use Turbo C++ even in this day and age. Unfortunately this is not something this community can fix. If you find yourself in this situation, prepare to not being able to get much outside help.
Turbo C++ is a very old compiler and it is a little bit different from the GNU C++ compiler. The code you shared will work perfectly with the GNU compiler but to run it with Turbo C++ you need to make a few changes:
1. Change the name of header file from iostream
to iostream.h
2. And remove the line "using namespace std" It is not required in Turbo C++.
Here is the modified code:
#include <iostream.h>
int main()
{
cout << "Hello, World!";
return 0;
}