how use global variables instead of local in c++
C++
#include<iostream>
using namespace std;
int x; // Global x
int main()
{
int x = 10; // Local x
cout<<"Value of global x is "<<::x<<endl;
cout<<"Value of local x is "<<x;
getchar();
return 0;
}
Also in C++:
- Title
- gfg top view of tree
- Category
- C++
- Title
- c++ empty stream
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- what is time complexity of min_element()
- Category
- C++
- Title
- c++ compiler for sublime text
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- howt o initialize 3d vector in c++
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- COnvert string to char * C++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- c++ string^ to char*
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- how to print a string to console in c++
- Category
- C++
- Title
- else if c++
- Category
- C++
- Title
- remove item from layout
- Category
- C++
- Title
- how to make a 2d vector in c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- compile c++ linux
- Category
- C++
- Title
- placement new c++
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- generate random double c++
- Category
- C++
- Title
- calling a method on an object c++
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- how to iterate through a map in c++
- Category
- C++
- Title
- apple and orange hackerrank solution in c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- c++ how to add something at the start of a vector
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- how to convert int to string c++
- Category
- C++
- Title
- how to find hcf in c++
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- error: redefinition of ‘class Customer’
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- double max value c++
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- Convert binary tree to a doubly linked list
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- pair c++
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- length of array in cpp
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- array 2d to 1d
- Category
- C++
- Title
- how to convert number to string
- Category
- C++
- Title
- sleep system function linux c++
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- calling by reference c++
- Category
- C++
- Title
- inverser les éléments d'un tableau manuellement en c++
- Category
- C++
- Title
- cpp nan value
- Category
- C++
- Title
- how to input multiple lines of a file in c++
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- Get handle in C++
- Category
- C++
- Title
- how to get last element of set in c++
- Category
- C++
- Title
- Check if a Number is Odd or Even using Bitwise Operators
- Category
- C++
- Title
- roscpp publish int32
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- initialize 2d array c++
- Category
- C++
- Title
- c++ triple
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- c++ declare char
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- c++ for loop
- Category
- C++
- Title
- how to get a letter from the users string in c++
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- add a timer c++
- Category
- C++
- Title
- fill c++
- Category
- C++
- Title
- memset c++
- Category
- C++
- Title
- check an stack is empty c++
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- how to check a number in string
- Category
- C++
- Title
- find_if c++ example
- Category
- C++
- Title
- primos menores que
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- can we compare a long long int with int in c++ using max or min functions
- Category
- C++
- Title
- exponenciacion binaria
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- std::iomanip c++
- Category
- C++
- Title
- expected initializer before 'isdigit'|
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- c++ class inheritance
- Category
- C++
- Title
- static_cast c++
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++