CPP/Namespaces

From ProgrammingExamples
< CPP
Revision as of 08:46, 23 June 2010 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Namespaces.cpp

#include <iostream>
 
namespace Namespaces
{
  double add(const double a, const double b)
  {
	  return a + b;
  }
}
 
int main(int argc, char *argv[])
{
 
  //cout << add(3.4, 4.2); //does not work - "add was not declared in this scope"
 
  std::cout << Namespaces::add(3.4, 4.2);
 
  return 0;
}