Function overloading — two functions only differ by a default parameter

前端 未结 7 2076
有刺的猬
有刺的猬 2020-12-06 07:21
class A{
    public:
        void foo(int x)
        {
            cout << \"foo with one\\n\";
        }

        void foo(int x, int y=10)
        {
                 


        
相关标签:
7条回答
  • 2020-12-06 08:10

    Think about it - at compile time the compiler has to decide what one to chose. I cannot unless you supply both parameters. So the compiler has no choice but to throw its hands up and say that try again with code that does not require Mystic Meg.

    0 讨论(0)
提交回复
热议问题