Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Use const_cast to cast parameter before passing it into a function

#include <iostream> using namespace std; void print (char * str) {   cout << str << endl; } int main () {   const char * c = "sample text";   print ( const_cast<char *> (c) );   return 0; }