The problem with using namespace XXX and using XXX:xxx;.

using namespace Exercise; does not cause ival"s redeclaration,
but using Exercise::ival; instead leads to why redeclaration is;

such as the following code:

-sharpinclude <iostream>

using namespace std;
namespace Exercise
{
    int ivar = 0;
    double dvar = 0;
    const int limit = 1000;
}

// using namespace Exercise;
using Exercise::ivar;
int ivar = 0;
CPP
Jun.07,2022

The

namespace is to solve the problem of naming conflicts, but your using Exercise::ivar; is equivalent to the ivar variable in Exercise , that is, it is not ivar and using Exercise::ivar that conflicts, but you declare using Exercise::ivar
the following code will be fine, because there is no declare using Exercise::ivar

again.
-sharpinclude <iostream>

using namespace std;
namespace Exercise
{
    int ivar = 0;
    double dvar = 0;
    const int limit = 1000;
}

// using namespace Exercise;
int ivar = 0;
int main()
{
    cout<<Exercise::ivar;
    cout<<ivar;
    return 0;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea1069-4eff3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea1069-4eff3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?