-moz-user-select:none; -webkit-user-select:none; -khtml-user-select:none; -ms-user-select:none; user-select:none;

Monday 28 September 2015

Example of pointers in C++

As we know that a pointer is a variable whose value is the address of another variable. To demonstrate it,consider the following example.


Source code


#include <iostream>

using namespace std;

int main ()

{

   int  var1;

   cout << "Address of var1 variable: ";

   cout << &var1 << endl;

   return 0;

}

Output


Example of pointer
Example of pointer


Reference


To know the reference of this blog,

Friday 11 September 2015

Object Oriented Programming in C++ by Robert Lafore

Introduction

"OOP in C++" book

Object Oriented Programming in C++

Object-Oriented Programming in C++ begins with the basic principles of the C++ programming language and systematically introduces increasingly advanced topics while illustrating the OOP methodology. While the structure of this book is similar to that of the previous edition, each chapter reflects the latest ANSI C++ standard and the examples have been thoroughly revised to reflect current practices and standards.

 Author:

                  Robert Lafore

Date of publishing:

                                 December 29, 2001

Publisher:

                    
                                   Sams Publishing

Language:


                  English

Genre: 

    
            Programming

ISBN:

   
          
  •                       ISBN-10: 0672323087
  •                       ISBN-13: 978-0672323089

Rating:


             4.5/5 stars

Votes:

  
            54

Reviewer:


                David Horn

Review date:


                     January 30, 2004

Reviewer rating:


                            5/5 stars

Download link:


                    
                         Click here

Thursday 3 September 2015

Concept of pointers in C++

Pointers are an extremely powerful programming tool. They can make some things much easier, help improve your program's efficiency, and even allow you to handle unlimited amounts of data. For example, using pointers is one way to have a function modify a variable passed to it. It is also possible to use pointers to dynamically allocate memory, which means that you can write programs that can handle nearly unlimited amounts of data on the fly--you don't need to know, when you write the program, how much memory you need.      

Concept of pointers

Pointers are aptly named: they "point" to locations in memory. Think of a row of safety deposit boxes of various sizes at a local bank. Each safety deposit box will have a number associated with it so that the teller can quickly look it up. These numbers are like the memory addresses of variables. A pointer in the world of safety deposit boxes would simply be anything that stored the number of another safety deposit box. Perhaps you have a rich uncle who stored valuables in his safety deposit box, but decided to put the real location in another, smaller, safety deposit box that only stored a card with the number of the large box with the real jewelry. The safety deposit box with the card would be storing the location of another box; it would be equivalent to a pointer. In the computer, pointers are just variables that store memory addresses, usually the addresses of other variables. 

Declaration of pointers

The general form of a pointer variable declaration is:
type *var-name;
Here, type is the pointer's base type; it must be a valid C++ type and var-name is the name of the pointer variable. The asterisk you used to declare a pointer is the same asterisk that you use for multiplication. 


Reference

The reference of this blog is taken from