I'm very new to C++ so I'm hoping someone would shed some light. I came across several similar topics but I just need clarification.

So it seems it's valid to pass a local string that has been declared but not initialized to a function. But why does compiler complain when you try it with int or float??

Whether it's string, float, or int, memory address gets referenced when it is declared even tho it may be "garbage"

```
#include <iostream>
using namespace std;

void load(int);

int main()
{
    int salary;
    load(salary);
    return 0;
}

void load(int sal)
{
    cout << "your salary: " << endl;
    cin >> sal;
    cout << sal << endl;
}

```

If I declare int or float as global variable, it works as expected without any warnings.
So then is it a better practice to declare variable in global space (I hope not)?

So putting it in global, it works :

```
#include <iostream>
using namespace std;

int salary;
void load(int);

int main()
{
    load(salary);
    return 0;
}

void load(int sal)
{
    cout << "your salary: " << endl;
    cin >> sal;
    cout << sal << endl;
}

```

ok, another example to show that uninitialized global variable works when passing to function as value : (going off of David's comment)

```
int foo; 
int returnit(int j)
{ 
    cout << "your salary";
    cin >> j;
    return j; 
} 
int main() 
{ 
    int k = returnit(foo);
    cout << k; 
    return 0;
} 

```

anyways, lesson here is to initialize primitive data types before passing to functions.