PrevUpHomeNext

day-11: 5 minutes: c++ namespace


c++ namespace 5 minutes, maybe 3 minutes

namespace

std::cout << std::endl;

std is a namespace.

Create your own namespace

Make your own namespace

namespace my_space
{
	float x = 2.5f;
}

std::cout << my_space::x << std::endl;

Make your own nested namespace 1

namespace my_space::my_name
{
	float x = 5.2f;
}

std::cout << my_space::my_name::x << std::endl;

Make your own nested namespace 2

namespace my_space
{
	namespace my_star
	{
		float x = 2.5f;
	}
}

std::cout << my_space::my_star::x << std::endl;

Written on Oct 31, 2024

Back

Up: day-11: Miscellaneous

Index

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ==================================================
  #        The c++ programming language.           #
  #                                                #
  #        Home: cppfx.xyz                         #
  #        Join c++ Discord: yZcauUAUyC            #
  #        Deck                                    #
  ==================================================

PrevUpHomeNext