what is the difference between pointer variable & simple variable ?(the difference other than stores address )
what is template in c++?


Well, you mentioned the difference - one has the address which needs * (indirect) operator to access the value, and one holds the value that can be used as is:

int i = 4, j;
int ptr_to_i = &i;

++i; // i is 5
j = *ptr_to_i;  // j is 5
++*ptr_to_i; // i is 6
++ptr_to_i; // points PAST i (and is not valid to use * on).

A template is like a macro, but allows the compile to know the type of the underlying object.  For example, in STL, a list is a template, but when used with your class, allows you to have a list of your class.  References to items in the list allow you to reference the object members and member functions directly.  Search for examples on the WEB, there are great references for this.



All Answers

Answers by Expert:

Ask Experts


Bill A


I can answer questions about C++, programming algorithms, Windows programming in MFC (which is C++). I cannot answer questions about STL (templates) and I have no experience with Linux. I do enjoy reviewing code and critiquing it or finding problems in it. I will also gladly show better algorithms or methods if you want to take advantage of that.


I've developed a commercial embedded C compiler/assembler and IDE with debugger toolset, of which the IDE and debugger are written in C++. I work in the industry writing high tech embedded programs and Windows programs to communicate with the embedded devices.

Book: Embedded Systems Design using the Rabbit 3000 Microprocessor Authored Chapter 10 in its entirety.

BS Computer Engineering

©2016 About.com. All rights reserved.