Nested Namespaces - C++ Statement

C++ examples for Statement:namespace

Introduction

You can define one namespace inside another.

namespace outer
{
  double max(const std::vector<double>& data)
  {
    // body code..
  }

  double min(const std::vector<double>& data)
  {
   // body code..
  }

  namespace inner
  {
    void normalize(std::vector<double>& data)
    {
       // ...
       double minValue {min(data, size)};   // Calls max() in outer namespace
       // ...
    }
  }
}

void outer::inner::normalize(std::vector<double>& data)
{
  // ...
  double minValue{min(data)};          // Calls min() in outer
  // ...
}

Related Tutorials