rutura/The-C-20-Masterclass-Source-Code

U forget to call the function

Nickranjan opened this issue · 0 comments

067 source code (c++ lecture )
https://github.com/rutura/The-C-20-Masterclass-Source-Code/tree/main/9.VariableLifetimeAndScope/9.2VariableScope

Because of this issue , only we get output from the main function, not from the local function. program must be like this ..

#include<bits\stdc++.h>

int global_var1{23};

void some_function()
{
int local_var{10};
std::cout<< " Inside function global_var"<< global_var1<< std::endl;
std::cout<< " Inside function local_var :"<< local_var<< std::endl;
}

void some_other_function()
{
std::cout<< " Inside function global_var"<< global_var1<< std::endl;
//local_var=5;

}

int main ()

{
some_function();
some_other_function();

   std::cout<< " Inside main function global_var" << global_var1<<std::endl;
   
   return 0;

}