fbpx

C++ Interview Questions

Bjarne-stroustrup
 
Prev2 of 17Next

According to the C++11 standard, what is the output of this program?

#include <iostream>
#include <string>

void f(const std::string &) { std::cout << 1; }

void f(const void *) { std::cout << 2; }

int main() {
	f("foo");
	const char *bar = "bar";
	f(bar);
}

Answer