Answer: In some scenarios, we can have both the
inner and
outer namespaces containing the types with the same name. At this point,
name hiding is used.
It states that the priority is given to the type that is present in the
inner namespace.
Example,
namespace Home
{
namespace Hall
{
class Television { }
class Furniture { }
namespace DiningRoom
{
class Furniture { }
class Color
{
Furniture DiningFurniture; // Hall.DiningRoom.Furniture (Because of higher priority)
Hall.Furniture HallFurniture; // Hall.Furniture
}
}
}
}
Asked In: Spotted While Learning |
Alert Moderator