C++ Abstract class can't have a method with a parameter of that class

后端 未结 4 1103
一向
一向 2021-02-04 04:25

I created this .h file

#pragma once

namespace Core
{
    class IComparableObject
    {
    public:
            virtual int CompareTo(IComparableObject obj)=0;
          


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 04:54

    From C++03, §10.4 3:

    An abstract class shall not be used as a parameter type, as a function return type, or as the type of an explicit conversion. Pointers and references to an abstract class can be declared.

    Passing obj as a const reference is allowed.

提交回复
热议问题