Difference between revisions of "CPP/Namespaces"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Created page with '==Namespaces.cpp== <source lang="cpp"> #include <iostream> namespace Namespaces { double add(const double a, const double b) { return a + b; } } int main(int argc, c…')
(No difference)

Revision as of 08:46, 23 June 2010

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;
}