Horje
explicit c++ Code Example
explicit c++
#include <iostream>
#include <cstring>

Class MyClass{
public:
  explicit MyClass(const char* str){
    std::cout << str << std::endl;
  }
};

int main(int argc, char* argv[]){
  std::string title = "Hello World!";
  MyClass obj1(title); // This will not compile, because with explicit
  //                      keyword we blocked implicit convertion from
  //                      std::string to const char*
  MyClass obj2(title.c_str()) // Now it works, because we paste in a
  //                      const char* with c_str() method!
  
  return 0;
}




Cpp

Related
factorial MOD 998244353 Code Example factorial MOD 998244353 Code Example
how to set arrays as function parameters in c++ Code Example how to set arrays as function parameters in c++ Code Example
initializer before void c++ Code Example initializer before void c++ Code Example
Lucky Four codechef solution in c++ Code Example Lucky Four codechef solution in c++ Code Example
c++ abs template Code Example c++ abs template Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9