Sunday, August 29, 2010

How to use Pointer in c tutorial | Pointers in Cplusplus | pointer in c language

,
What is Pointer?

Pointer is very important in C and C++. It's  a variable which stores memory of user type and primary variable. It Hold the value of memory of a variable.

Why we use Pointer?
Some time we need to storing the address of variable for solving this problem we use pointer which capable to storing the memory address of a variable.

Guideline for using pointer
1. Define * When we use pointer
2. when we store address of pointers of pointer then we use **variable name

Example of Pointer

#include<iostream.h>

int main ()
{
int first,second;
int * ptr;
ptr = &first;
*ptr = 10;
ptr = &second;
*ptr = 20;
cout << "first is " << first << endl;
cout << "second is " << second << endl;
return 0;
}

Output:- First is =10
Second is =20
Read more →

String Operations in cplusplus

,
String Handling:-A string is a collection of  characters.String is  a class in cplusplus and there are three constructors in the String class.
1.)String():-For creating an empty string
2.)String(Const char *str):-For creating a string object from a null terminated string
3.)String(const string &str):-For creating a string object from other string object

#include<iostream.h>
#include<string.h>
void main( )
{
char ch1[] = “Cplusplusexample”;
char ch22[80];
for(int i=0; i
ch2[i]=ch1[i];
ch2[i]=’\0’;
cout<< “The copied string is “<< ch2;
}
Output:-The copied string is Cplusplusexample
Read more →

Exception Handling in Cplusplus

,
Exception handling:-Exception Handling is used in object oriented programming.It is feature by which we can handle easily a lot of feature.so that u can easily debug the code and to find the where the actual problem reside.In the Exception Handling we can use the try and the catch block
In the try block we can use the code in which the error may be occured that are to be placed in try block.
In the catch block particular error are to be handled in which way.The solution of particular error are provided in the catch block.
Example:-
#include<iostream.h>
int  main()
{
int a,b;
cout<<”Enter Values of a and b\n”;
cin>>a>>b;
int x=a-b;
try
{
If(x!=0)
{
cout<<”Results(a/x)=”<<<”\n”;
}
else
{
 throw(x);
}
}
catch(int i)
{
cout<<”Exception Caught :x=”<<<”\n”;
}
cout<<”END”;
return 0;
}

Output1:-            Enter Values of a and b
                                400       20
Result(a/x)  =   20
END

Enter Values of a and b
                                20           20
Exception Caught:   x =   0
END


Read more →

Thursday, August 26, 2010

Vectors

,
Read more →

Function overriding in c++ | What is Function overriding

,
Read more →

Recursion

,
Read more →

Access Modifiers

,
Read more →

What is Base class in c++ and How to use with derived class c++

,
Read more →

Derived class

,
Read more →

Preprocessor directives

,
Read more →

Difference between Structure and classes

,
Read more →

Command Line Arguments

,
Read more →

Example of constructor overloading c++ | How to Constructor Overload

,
class CO
{
   private:
       int a;
       int b;
       int c;
  public:
      CO(int x,int y,int z);
      CO(int x,int y);
      CO();
      void   show()
      {
          cout<<"\na="<<"b="<<<"c="<
      }
};


Read more →

Array Of objects

,
Read more →

Delete Operator

,
Read more →

Memory Management Operators

,
Read more →

cout object

,
Read more →

cin object

,
Read more →

Compiling and linking

,
Read more →

Structure of C++ Program

,
Read more →

Nesting of Classes

,
Read more →

Dynamic Binding

,
Definition of Dynamic Binding:-Binding means that  a procedure call of the code is executed , when we call the particular code.
Dynamic Binding means at the run time we know that which code is particularly associated to which code.
Dynamic Binding also known as Late Binding.
It is generally associated with polymorphism and Inheritance.
Read more →

Data Hiding

,
Read more →

Message Passing

,
A mesage for an object is a request for execution of a procedure,and therefore will invoke a function in the receiving object that generates the desired result

Example:-Employee.salary(name);
Read more →

Encapsulation

,
What is Encapsulation?

The packing of data member and member functions into a single component is called Encapsulation.The data is not reached by the outside functions.Only those functions that are able to access the data are defined within a class.Class is the best example of Encapsulation.
Read more →

Abstraction

,
Read more →

Compile time polymorphism

,
Read more →

Runtime Polymorphism

,
Read more →

Late Binding

,
Read more →

Early Binding

,
Read more →

Arrays In Cplusplus

,
Read more →

Do-While Loop

,
Read more →

While-Loop

,
Read more →

For-Loop

,
Read more →

Polymorphism

,
Read more →

Default Constructor

,
Read more →

Monday, August 16, 2010

Scope Resolution Operator

,
Definition of Scope Resolution Operator:-The scope access(or resolution operator)operator :: (the two semicolons)allow programmers to access a global name even if it is hidden by a local re-declaration of that name.
When we declare a variable it is available only to a specific part or block of the program.Remaining block cannot access the variable .The area of a block where the variable is accessed is known as the scope resolution operator.


Example:-#include
int a=10;
main()
int a=20;
cout<<"::a"<<::a;
cout<<"a="<
return 0;

Result:- 10
20
Read more →

Operators

,
Read more →

Saturday, August 14, 2010

Constants

,
Definition Of Constant:-The constants in C and C++ are applicable to the values ,which do not change during the execution of a program.
There are a several type of constants in C and C++.They are Claasified into various categories are as follows:-
1.)Integer Constant
2.)Real Constant
3.)Character Constant
4.)String Constant

1.)Integer constant:-Integer constants are those who provide the numbers are either positive or negative.
Example:-const int a=5;

2.)Real Constant:-The real constants can be written in exponential notation,which contains a fractional part and an exponential part.
Example:-Const float=3.4;

3.)Character Constant:-A character constant is a single character constant.A digit,alpahabets,white space enclosed with a pair of single quote marks.
Example:-Const char ch='a';

4.)String Constants:-A String constant is a collection of characters enclosed with a pair of double quote marks.
Example:-"Anusha";







Read more →

Identifiers

,
Definition of Identifiers:-Identifiers are the names of variables,functions,arrays and classes.They are the user-defined names,consisting of sequence of letters and digits.The underscore is also permitted if u want ,u can use it according to need.

Example:- 1.) Class person
{ };
2.)void show
{ };
Read more →

Keywords

,
Read more →

Tokens

,
Read more →

Enumerated data Types

,
Read more →

Function Overloading

,
#include<iostream.h>
#include<conio.h>
Int sqr  (int);
Float sqr (float);
Main ()
{
Clrscr ();
Int a= 15;
Float b = 2.5;
Cout <<”Square =”<<<”/n”;
Cout <<”Square =”<<<”/n”;
Return 0;
}
Int sqr (int s)
{
Return (s*s);
}
Float sqr (float j)
{
Return (j*j);
}

OUTPUT

Square = 225
Square = 6.25

Read more →

Operator Overloading

,
Read more →

Copy Constructor

,
Read more →

Parameterized constructor

,
Read more →

Destructor

,
Read more →

Static functions

,
Read more →

Typecasting in C and C++

,
Read more →

Inline functions

,
Read more →

Default Arguments

,
C++ lets the programmer to assign default values in the function prototype declaration of the function.When the function is called with less parameter or without parameters the default values are used for the operations .It is not allowed to assign default values to any variables,which is between the variable list.

Example:-

#include<iostream.h>
#include<conio.h>
int main()
{
Clrscr ();
int sum (int a, int b=10, int c=15, int d=20);
Int a=2;
Int b=3;
Int c=4;
Int d=5;
Cout<<”Sum=”<
Cout<<”/nSum=”<
Cout<<”/nSum=”<
Cout<<”/nSum=”<
Cout<<”/nsum=”<
Return 0;
}
Sum(int j, int k, int l, int m)
{
Return (j+k+l+m);
}

OUTPUT :

Sum = 14
Sum = 29
Sum = 40
Sum = 47
Sum = 32

Read more →

Manipulators

,
Read more →

This Pointer

,
Read more →

Data Types in c++

,
Read more →

Interfaces

,
Read more →

Abstract Class

,
Read more →

Virtual Base Class

,
Read more →

Pure Virtual functions

,
Read more →

Virtual functions

,
Read more →

Hybrid inheritance

,
Hybrid Inheritance:- It is a combination of two of the inheritance Multiple and hierarchical
Inheritance

Example:-
class A
{
A()
{

Cout<<”I m in A”;
}
};
Class B:public A
{
B()
{
Cout<<”I m in B”;
}
};
class C:public C
{
C()
{
Cout<<”I m in C”;
}
};
Class D:public B,public C
{
D()
{
Cout<<”I m in D”;
}
};
Voi d main()
{
D d;
}

Output:-
I m in A
I m in B
I m in C
I m in D
Read more →

Hierarchical inheritance

,
Hierarchical Inheritance:-In the Hierarchical Inheritance there is only base class and all
the derived classes are derived from this base class.
Example:-
class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B:public A

{
B()
{
Cout<<”I m in B”;
}
};
class C:public A
{
C()
{
Cout<<”I m in C”;
}
};
Class D:public A
{
D()
{
Cout<<”I m in D”;
}
};
Voi d main()
{
D d;
}

Output:-
I m in A
I m in B
I m in C
I m in D
Read more →

Multilevel Inheritance

,

 Multilevel Inheritance:-In the Multilevel Inheritance there is one base class and other class which is derived from this base class is called derived class. The process of deriving a class  from another derived class.


class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B:public A
{
B()
{
Cout<<”I m in B”;
}
};
class C:public B
{
C()
{
Cout<<”I m in C”;
}
};
Class D:public C
{
D()
{
Cout<<”I m in D”;
}
};
Void main()
{
D d;
}


Output:-I m in A
I m in B
I m in C
I m in D



Read more →

Multiple Inheritance

,
Multiple Inheritance:-I n the multiple Inheritance there will be many base classes and there is only one derived class which derives from all the base classes.

Example:-
class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B
{
B()
{
Cout<<”I m in B”;
}
};
class C
{
C()
{
Cout<<”I m in C”;
}
};
Class D:public A,public B,public C
{
D()
{
Cout<<”I m in D”;
}
};
Voi d main()
{
D d;
}

Output:-
I m in A
I m in B
I m in C
I m in D
Read more →

Single Inheritance

,
Single Inheritance:-In the Single Inheritance there will only one base class and only one derived class.It should be like this.
Example:-
class A
{
A()
{
Cout<<”I m in A”;
}
};
Class B:public A
{
B()
{
Cout<<”I m in B”;
}
};
Voi d main()
{
B b;
}

Output:-I m in A
I m in B
Read more →

C++ Description

,
Read more →

Difference between C and C++

,
Read more →