C++ basics
/************************/
In C++, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.
/************************/
C++ does not recognize the end of the line as a terminator.
/************************/
C++ KEY WORDS
\asm else new this
auto enum operator throw
bool explicit private true
break export protected try
case extern public typedef
catch false register typeid
char float reinterpret_cast typename
class for return union
const friend short unsigned
const_cast goto signed using
continue if sizeof virtual
default inline static void
delete int static_cast volatile
do long struct wchar_t
double mutable switch while
dynamic_cast namespace template
/************************/
A local variable is known only to the function in which it is declared.
/************************/
A formal parameter is a local variable that receives the value of an arument.
/************************/
Now, it is the most interesting part-pointer.
Pointers are without doubt one of the most important-and troublesome-aspects of C++. In fact, a large measure of C++'s power is derived from pointers. They allow C++ to support such things as linked lists and dynamic memory allocation.
A pointer is a variable that contains the address of another object.
To declare P to be a pointer to an integer, use the declaration: int *P
a pointer to a float, use the declaration: float *P
There are twp special operators that are used with pointers: * and &.
Let's see the simple example.
#include<iostream>
using namespace std;
int main()
{
int balance;
int *balptr;
int value;
balance = 300;
balptr = &balance;
value = *balptr;
cout << " balance is : "<< value << '\n'<<endl;
return 0;
}
The output is shown here.
balance is: 3200
/************************/
The base type of pointer is important. It determine the how many bytes of address the compiler would transfer for the pointer types.
/************************/
Assigning Values Through a Pointer
#include <iostream>
using namespace std;
int main()
{
int *p, num;
p = #
*p = 100;
cout << num << ' ';
(*p)++;//Here is call back the value which is stored in the p.
cout << num << ' ';
(*p)--;
cout << num << '\n';
return 0;
}
The output from the program is shown here.
100 101 100
/************************/