-2

Currently,I am learning C++ and I observed that objects like vectors,lists can be used if we include their respective header file and std::object_name.Where these classes are actually defined,in their respective header files or in std namespace?

yondu_udanta
  • 797
  • 1
  • 6
  • 13

1 Answers1

2

The namespace std is slit over many files, and not all defined in one place. Unlike a class, a namespace can be reopened and have new declarations added.

For example, the templates like std::vector are both declared and defined in their respective headers, because Why can templates only be defined in the header file?.

Other members of namespace std can be declared in a header, and defined in a cpp file. That cpp file is probably already compiled into a runtime library that your program links to.

Community
  • 1
  • 1
Bo Persson
  • 90,663
  • 31
  • 146
  • 203