What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void print (char * a)
{
cout << a << endl;
}
int main ()
{
const char * a = "Hello world";
print(const_cast (a) );
return 0;
}
#include <iostream>
using namespace std;
void print (char * a)
{
cout << a << endl;
}
int main ()
{
const char * a = "Hello world";
print(const_cast (a) );
return 0;
} A. Hello world
B. Hello
C. world
D. compile time error
Answer: Option A

Join The Discussion