C++ variable scope explained 🌎

preview_player
Показать описание
#local #global #variables

Local and global variable scope in C++ tutorial example explained
Рекомендации по теме
Комментарии
Автор

#include <iostream>

int myNum = 3; //global

void printNum();

int main()
{
int myNum = 1; //local
printNum();
std::cout << "main: " << myNum << '\n'; //local
//std::cout << ::myNum << '\n'; //global

return 0;
}
void printNum(){
int myNum = 2; //local
std::cout << "printNum: "<< myNum << '\n'; //local
//std::cout << ::myNum << '\n'; //global
}

BroCodez
Автор

I really like your C++ series. Keep it up. Please make more C++ Videos. So, let's defeat the YouTube algorithm.

FrederikWollert
Автор

std::cout << "good job" << std::endl;

yahyaarfaoui
Автор

what do you mean by " "pollutes" the global namespace " ?

oximas-oevf
Автор

so what is printNum and how is it related to myNum

Nightmare-boxi
Автор

#include <iostream>
int P =3.14;
int main(){
std::cout<<“p\n”;

Returno 0;}

parpaperchimp
Автор

comment = rand(random_comment) % 100;

wlsedlacek
Автор

std::cout << " Great job ", , endl;

artemzakharchuk