...

Programming languages - C++

Back to Course

Lesson Description


Lession - #37 C++ Variable Scope


An scope is an area of the program and by and large are three spots, where variables can be proclaimed −

  • Inside a function or a block which is called local variables,
  • In the meaning of function parameters which is called formal parameters .
  • Beyond all functions which is called global variables.

Local Variables

Variables that are proclaimed inside a capacity or square are neighborhood Variables . They can be utilized simply by explanations that are inside that function or block of code. Local Variables are not known to functions outside their own. Following is the model utilizing neighborhood Variables −
 

#include 
using namespace std;
 
int main (>
{ // Local variable declaration: int a, b; int c; // actual initialization a = 10; b = 20; c = a + b; cout << c; return 0; }

 

 

Global Variables

Global variables are characterized beyond every one of the functions, as a rule on top of the program. The global variables will hold their worth all through the life-season of your program.

A global variables can be gotten to by any function. That is, a global variable is accessible for use all through your whole program after its announcement. Following is the model utilizing global and local variables −

 

 

 

 

#include 
using namespace std;
 
// Global variable declaration:
int g;
 
int main (>
{ // Local variable declaration: int a, b; // actual initialization a = 10; b = 20; g = a + b; cout << g; return 0; }

 

 

 

 


There are 4 major oop principles c++ that make an language Object Oriented. These are Encapsulation, Data Abstraction, Polymorphism and Inheritance
sleep MSVC is a CRT function, and Sleep is a Windows API
OOPS Concepts In C# — Object-Oriented Programming is a programming model that works on a principle that revolves around objects rather than action or logic.
c plus plus object oriented Programming. Procedural programming is about writing procedures or functions that perform operations on the data, while object-oriented programming is about creating objects that contain both data and functions.
The Borland C++ Compiler 5.5 (BCC>
is a blazingly fast 32-bit optimizing compiler.