(::) 2 :
a) //typedef ( ) :
int fun()
{
return 1;
}
namespace x
{
using ::fun;
}
int main()
{
std::cout << fun() + x::fun();
}
. STL, : std::size_t:
typedef unsigned int size_t;
namespace std
{
using ::size_t;
}
size_t x = 1;
std::size_t y = 2;
b) :
# include <algorithm>
using namespace std;
template<class T> inline
void swap(T &left, T &right)
{
T tmp = left;
left = right;
right = tmp;
}
int main()
{
int a = 1, b = 2;
std::swap(a, b);
::swap(a, b);
}
- Note:
using namespace std;not recommended practice.
Edit
The MSVC compiler provides macro _CSTD( #define _CSTD ::), so you can use using _CSTD fun;, etc if you want.
source
share