-3

I have happened to read a function definition like this:

virtual void printMarksheet() const = 0;

I thought initially that the syntax may be incorrect. So I wrote a dummy code to check. I wrote the following code and compiled. It compiled successfully. But I would like to know the meaning of the line. Is it function definition? or function declaration? What is the significance of const=0.

class Marksheet
        {
        public:
            virtual void printMarksheet() const = 0;
        };
        int main()
        {
            return 0;
        }

1 Answers1

0

Its a function declaration. const=0 are two different things. By defining const, the function will not be able to change the data member value. By defining =0, the function declared as pure virtual function.

Sumeet
  • 779
  • 6
  • 20