Function overloading — two functions only differ by a default parameter

前端 未结 7 2119
有刺的猬
有刺的猬 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:01

    Why not?

    class A{
        public:
    
            void foo(int x=10, int y=10)
            {
                cout << "foo with two\n";
            }
    };
    

提交回复
热议问题