paizza paizza - 1 month ago 5x
C++ Question

Which kind of explicit conversion is done here?

This is the code that compile and works in my MVS2015:

#define STRING_TEST "Test String"

using namespace std;

void test(char * str) {
cout << str;

int main ()

I guess that STRING_TEST was converted into a char[11]. Instead, since I pass it without
, it creates a char * pointer? Or what am I missing?


"Test string" is of type const char[12], not char[11] (you forgot '\0').

Your code is equivalent to

test("Test String");

Macros just do a find+replace, so it's not "converted".

Arrays decay into pointers, to here, the char arrays decays into char*. And so test calls it. This however is has been removed as of C++, since const char* != char*.