Machine-translated by Google. Questions are authored in English.
Top

Discussion

The output of the code below is

void m(int k)
    {
        printf("hi");
    }
    void m(double k)
    {
        printf("hello");
    }
    void main()
    {
        m(3);
    }

 

  • A.hi
  • B.hello
  • C.Compile time error
  • D.Nothing

Answer: C

Correct answer: Compile time error

C has no function overloading: two functions cannot share a name, whatever their parameters. The compiler reports a redefinition. In C++ this would compile, and m(3) would select the int version.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.