Free Facebook Likes | Twitter Tweets Followers


All programming tutorials


first starting with c++

prerequisite for this is c some guys get books of deep c i hope

This tutor designed for noobs so anybody who knows c++ well just keep quiet and dont show off ur ...... etccc

i go slowly one chapter per day starting some theories it may quite boring pls adopt that

if u wont understand some concepts later we go by examples u can understand everything .....


after the session overs any doubts just leave ur questions here...

about compiler its ur wish ....

i wont help the compiler configuration and all ..... download it via software zones...

That's it

lets start
A little history

The C++ programming language was initially created by Bjarne Stroustrup, as a "better C". C++ was an attempt to extend and (to some extent) change the C programming language to overcome some problems. C++ standardized in 1998.
Should I Learn C First?

The question arises in ur mind .For my tutorial u should have learnt atleast upto for loop,functions. Because C++ is a superset of C. I have one good book for c named deep c …leave mail id in my scrap I will send through mail mention everything properly.

Comparison c++ with other languages ///


After learnin this tutorial …. Finally I will tell.



variables, conditional statements, loops ,operators, functions. These r similar in C.

What Is a Program?


The word program is used in two ways: to describe individual instructions, or source code,created by the programmer ex. Hello.cpp and to describe an entire piece of executable software.ex.hello.exe

Move to compiler
-----------------Top 6 c-c++ compiler-------------------


1. DevC++
2. MinGW Studio
3. GNU Emacs and XEmacs
4. Microsoft Visual C++ 2005
5. Eclipse for C++ with CDT
6. Code::Blocks
Compiler types

16-bit compiler ex: familiar one turbo c++
32-bit compiler ex: Microsoft Visual C++ 2005
64-bit compiler
Wat makes difference
In 16 bit compiler the int size is 2 bytes
For 32 bit int size is 4 bytes
Check out using sizeof() operator

Now compiling phases

First u will create a code using any editor even our notepad is a editor.
Most of them have turbo c++ but i recommend move to mingw studio or Microsoft
Turbo c++ also u can practice


code:


#include
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}


And save it as hello.cpp

-->>Note: wait look the code once .. std ve u heard about it …. Note it that is namespace

continued......
>> When u compile ur code converted into hello.obj or hello.o

>>Before compilation, a special program called the preprocessor scans the source code and preforms simple substitution.

>>The preprocessor examines all lines beginning with # , performs the corresponding actions and macro replacements, and produces a preprocessed version of your program with the file name suffix .i. The .i file is created in a directory used to store temporary files.
>>Preprocessor is separate topic will be discussed elaborately later.

>>Compiler ensures that the code is valid(syntax checking like that) and will sequence into an executable program(sequence arrangement for execution). Under some compilers, you may get messages or warnings with your program


Zoom in (real dimensions: 295 x 800)Image


Wat this hello.obj or hello.o contains?

The .o or .obj contains the binary version of the source code which is not directly executable.


>>The final form hello.exe
Here we have one component named linker which combines the object codes into one complete program by integrating libraries(header files) and the code(program which contains 2 or more source codes in separate files ) and producing an executable program.

Wat is class and object?

Ex : Apple is a fruit
Class : fruit
Object :apple

(classes)
• Putting behaviors (functions) and attributes (data) together.
• A class does not exist in the memory of computer during program execution.
(Object)
• An instance of a class. There can be more than one instance for a class.


Frm above example
Consider fruit
Lets check out fruits attributes

(programmatic view inside C++ program looks like this…)

Fruit color - string strFruitColor;
Fruit name - string strFruitName;



Lets check out fruits behaviors
Fruit weight
int weight(string strFruitName)
{
// some code to find weight
return intFruitWeight;
}

code:

class Fruit {
// fields
string strFruitColor;
string strFruitName;

// a function
int weight(string strFruitName)
{
// some code to find weight
return intFruitWeight;
}
}

Variable: it is a memory space where u have to store the data of ur program. variable can change its data at runtime while program is running...

for ex:(don't see the whole code just check variable, otherwise u'll get confused)

To add two numbers:

#include<iostream.h>
#include<conio.h>
int main()
{
int a; // first number for addition(it is a variable, its name is "a")
int b; //second number for addition(it is also a variable,its name is "b" )
int sum; // THE VARIABLE WHICH STORES SUM OF TWO VARIABLES

cout<<"enter first number";
cin>>a;
cout<<"Enter second number";
cin>>b;


sum=a+b;


cout<<"SUM of a and b is "<<sum;
getch();
return 0;
}



in above example, a and b are two variables, which stores two int(integer or numeric) values. sum is also numeric/int variable which stores addition of a and b.

Now data types : In c++ there are 4 main datatypes for begineers .

1.INT (which stores numeric values)
2.FLOAT (which stores numeric values with decimal or we can say any ratonal numbers)
3.CHAR (it is used to store any character "or" single press of any key in keyboard is suppose to be a CHARACTER eg., a,z,g,h,3,8,',],+,(,*,m,a)
4.VOID (its value is always zero or null)

0 comments:

Post a Comment

 
Top