Warum hat std::vector 2 Konstruktoren statt 1 mit Standardargument?C++

Programme in C++. Entwicklerforum
Guest
 Warum hat std::vector 2 Konstruktoren statt 1 mit Standardargument?

Post by Guest »

Ich habe mir cppreference.com angesehen und Folgendes gefunden

Code: Select all

vector();
explicit vector( const Allocator& alloc );
Warum nicht einfach

Code: Select all

explicit vector(const Allocator& alloc = Allocator());
1 Konstruktor statt 2.
Gibt es einen Grund dafür? Gleiches gilt für resize(std::size_t,const T& t) und

Code: Select all

resize(std::size_t)
Warum nicht einfach resize(std::size_t,const T& t = T())

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post