Q. What happens if we execute the following code in C and C++?
Code:
#include<stdio.h>
struct STRUCT
{
int x;
int f()
{
printf("Welcom to StackHowTo\n");
}
};
int main()
{
struct STRUCT s;
s.f();
return 0;
}
β
Correct Answer: (D)
The program returns an error in C but works perfectly in C++.