Saturday, March 26, 2011

Lets step on to the amazing C++ world - Part 2 - Environment Contd..

Hello guys, I think now you're comfortable with the basic environment of C++. Today, I'm going to introduce you a new platform to compile C++ programs. That is visual C++ which is a Microsoft's implementation of C++. There are 6 main phases in visual C++.


       1.) Edit - Program is created in the editor and stored on the disk.
       2.) Preprocess -  Preprocessor, processes the code
       3.) Compile - Creates the object code and stores on the disk
       4.) Link - Linker links the object code with the libraries
       5.) Load - Loader puts program in memory
       6.) Execute - CPU takes each instruction and execute it, storing new data values also will happen as it     executes the program.


 Those are the main steps in visual C++. In Microsoft platform, there are two main compiler applications to compile and execute C++ programs. They are Visual C++ 6.0 and Visual C++.net. The difference between these two is, Visual C++ 6.0 produces an unmanaged code (Direct conversion of High Level Language to Machine Language using a compiler) and Visual C++.net produces a managed code (Using intermediate language between the High level language and the machine language.).


To work with this Microsoft's platform, you need to use "Namespaces". All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. In order to access its functionality we declare with this expression that we will be using these entities. std:: specifies using name that belongs to “namespace”. As an example, when you are using insertion operator (which will be discussed in the next lesson), we have to declare std : : cout; . So for library functions, we need to use this. But with a single statement "using namespace std;" we can avoid declaring it everywhere. So,, that's it about basics of the Visual C++ environment. You can use Visual C++ 6.0 or Visual Studio (for .net) to work with C++. But my preference is to work with Turbo C++ which I mentioned in previous lesson.


So... now you are up to speed to be a C++ programmer. Then Let's start with codings and C++ coding basics.  

Saturday, March 19, 2011

Lets step on to the amazing C++ world - Part 1 - Environment

Can a computer understand the language we speak? Can we directly give commands to the computer? In simple terms, can we communicate with the computer in our language? Simple answer is "NO". So, how can we communicate? Lets simply take an example, assume, we need to talk with a person who came from Siberia,, we don't know their language,, so how do we communicate? We gonna need a translator. So same as that, to communicate with the computer, we gonna need a translator. Because the language that the computer understands is, Binary Language. It's called the Machine language. There is another computer language type called assembly language (English-Like representing representing elementary computer operations) and we need assemblers (translator) to convert it to machine language.

Another language type is, High-Level languages. It's similar to English and uses common mathematical notations. There, a single statement accomplish substantial tasks. (Ex: TotalPay =  Payment + Bonus - Tax ). We need a translator programs (Compiler) to convert it to machine language or an interpreter which directly converts high level language programs.    

Computer program is a set of instructions that control the computer's processing of data. And C++ is a high level language which facilitates structured and disciplined approach to computer program design. And its an Object Oriented Language (We will discuss more on Object Orientation in future). To compile C++ programs you gonna need a compiler. A link to download a compiler is given below. If any problem occurs, please contact me by leaving a comment here. Download it and install it on your PC and we gonna need it from the next lesson.

Link to download a compiler :  http://www.4shared.com/file/K7WLGlcW/Borland_Turbo_C_45.html
Link 2 :  http://www.4shared.com/file/Vk41ajgi/Turbo_C_v45.html

After installing, open the program by double clicking the Turbo C++ icon. The main layout of the Turbo C++ is described below.

                                 Click on the image to enlarge it.

You can write programs by making new file and save it as name.cpp (*important). And first Build it by clicking Build Button and check for errors. And debug if there are errors. And then run the program. Lets move on to the coding. And lets start with C++ from the next discussion. :)

Friday, March 18, 2011

Lets Start with C++, My Favourite

Without any argument C++ is the most efficient, fast, flexible and interesting language that I've ever coded with.
Therefore with the grand opening of my 1st blog, I really would love to tell you about C++. As I know, it provides flexibility other than any other language because it has both the Object Oriented features and the memory concepts that we use in C which is the mother language of C++.


So,,lets talk a little bit about the history and the birth of C++. C++ was introduced to the world by Bjarne Stroustrup  at Bell Labs during 1983-1985 as an enhancement to the great C. And our subject C++s original name was "C with classes", but a little later it was named as C++ which is using all over the world and which is a leading, controversial and revolutionary language in the present world.

Lets start with it. This is for both the beginners and masters of C++ which flows as both the basic and advanced C++ concepts at the same time. For beginners, I'll be starting as "Lets step on to the amazing C++ world" and for ones who knows C++ basics, I'll be starting with "Advanced concepts of C++". So enjoy this series of posts and enjoy the world of C++.