Inline functions and variable scope in c++


My first ever question. On ‘maning-up’ to learn c++ I have myself in a tangle over scope. My understanding is that variables defined in functions should cannot be passe dout of scope. But I have been this like the below A LOT and it works everytime with no problems. What am i missing?

I have defined some inline functions in ns1.cpp like so:

namespace ns1 {

inline void func1(float f[3]);


ns1::func1(float f[3]){

//(do stuff to f)


Within a function far far away in class_a.cpp i consume typically like this:

include "ns1.h"


void class_a::func2(){

float f[3];


//f comes back in great shape! No runtime or compilation errors or anything.


My hunch is that either a) as the functions in ns1 are inline the compiler is putting the instructions for func1 within the scope of func2 and somehow not causing out of scope type errors or, b) im getting lucky and there are behaviour problems ahead of me.

Source: Windows Questions C++