Local variables might shadow global ones, that's what the ::
scope resolution operator is for
#include <iostream>
using namespace std;
int a=5;
int main()
{
int a=3;
cout << a; // 3
cout << ::a; // 5
}
so no ODR problems here.
As for the second example the function declaration inside another function (when it doesn't get confused by the most-vexing-parse), I recommend this question: Is there a use for function declarations inside functions?
And: no, you can't redefine your function inside main(). You can redeclare it (even with different parameters, thus declaring a new function) but that doesn't mean you can define it so.
There's an excellent excerpt from the wiki page which I recommend to read:
In short, the ODR states that:
In any translation unit, a template, type, function, or object can have no more than one definition. Some of these can have any number of declarations. A definition provides an instance.
In the entire program, an object or non-inline function cannot have more than one definition; if an object or function is used, it must have exactly one definition. You can declare an object or function that is never used, in which case you don't have to provide a definition. In no event can there be more than one definition.
Some things, like types, templates, and extern inline functions, can be defined in more than one translation unit. For a given entity, each definition must be the same. Non-extern objects and functions in different translation units are different entities, even if their names and types are the same.
Some violations of the ODR must be diagnosed by the compiler. Other violations, particularly those that span translation units, are not required to be diagnosed.1