-3

I was reading a book when I saw virtual void enter()=0; What does the asignment do while it is not a variable?

class MapSite { 
public: 
virtual void Enter() = 0; 
};
Omnifarious
  • 54,333
  • 19
  • 131
  • 194
moxeed
  • 3
  • 2
  • It doesn't do anything and wouldn't compile anyway, maybe you need to recheck the language you are working in – TheGeneral Jul 31 '19 at 04:58
  • What language? That isn't C# that would compile. – ProgrammingLlama Jul 31 '19 at 04:58
  • [Pure virtual function](https://stackoverflow.com/q/1306778/107625) in C++. – Uwe Keim Jul 31 '19 at 05:01
  • 1
    @UweKeim: Edits are not allowed to change the intent of the question. OP's intent, apparently, was to make this understandable to a C# programmer who mistakenly believes it is C#. Changing the tag completely loses that aspect of the question. – Ben Voigt Jul 31 '19 at 05:07

1 Answers1

5

That code is not C#, it is C++, and is the equivalent to C#

abstract class MapSite
{
    public abstract void Enter();
}

It makes the function pure virtual, and the class abstract. Subclasses will be abstract as well unless they provide a definition for the member function void Enter()

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • I'm wondering if I was right to mark it a dupe, since your point about being confused about the language is likely correct. – Omnifarious Jul 31 '19 at 05:10
  • @Omnifarious: I'm inclined to take a wait-and-see approach. If OP thinks it is different, he can let us know that opinion and then we can undo the dupe. – Ben Voigt Jul 31 '19 at 05:14