Easy learning with example program codes

CPP static

There are a list of words already defined in CPP library, same as in C. These reserved words are called as CPP Keywords. Every keyword is defined to serve a specific purpose. CPP static is one such keyword, which is used as a storage class to represent the scope of a variable within the program. CPP static has a local scope with a default value of 0. It is stored in RAM with a lifetime till the main program is completely executed. The static variable retains value between multiple functions call. The static keyword is memory efficient with a reason that it is not necessary to create instance for accessing the static members.


#include <iostream.h>
using namespace std;
class Student
string Name;  
float ID;
static string Section;   
Student(string Name, float ID) 	 
this-> Name = Name;    
this-> ID = ID;   
void details()
cout << "Section : " << Section << endl;
cout << "Student Name : " << Name << endl;
cout << "Student ID: " << ID << "\n\n";
string Student::Section= "6A";  
int main()
Student s1 = Student("Khush", 1);    
Student s2 = Student("Raam", 2);  
return 0;


Section : 6A    
Student Name : Khush      
Student ID: 1               
Section : 6A        
Student Name : Raam      
Student ID: 2
Posted in CPP   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki