const keyword and Protecting Array values
This video tutorial explains the const keyword used in c++.
You will learn what is the const keyword, what is the use of it, how to create a constant variable, how to declare a variable with const,how to protect the array values using the const keyword in detail with examples.
source code for this tutorial
#include <iostream> using namespace std; void display(const int num[],int limit); int main() { int number[] = {22,11,44,55,66}; display(number,5); return 0; } void display(const int num[],int limit){ for(int counter =0; counter < limit; counter++){ cout << num[counter] << endl; num[counter] = 22; } }