In C ++, when a method is declared, I noticed that sometimes a method can have an assignment attached to it.
Can anyone tell me what it is?
For instance:
virtual void MyMethod () = 0;
Which means "= 0". :)
Thanks everyone !!!
This means that it is a pure virtual function, i.e. there is no real definition in this class, and it must be redefined in the subclass. This is not actually an assignment per se, zero is the only value that you can “assign”.
++; # abstract.
abstract
++ , .
, . , , .
, .
, , , , .
#include <cstdio> class A { public: virtual void foo() const = 0; //pure virtual }; void A::foo() const { puts("A::foo"); } class B: public A { public: virtual void foo() const { puts("B::foo"); } }; int main() { //A a; //this would be an error - main point of having pure virtual functions B b; b.foo(); b.A::foo(); }
, , , ( ).
In C #, this is a syntax error.
If you meant C ++, see the answer "calm."
Source: https://habr.com/ru/post/1761178/More articles:Maturity Script # (compared to GWT) - javascriptHow to integrate CMS into an existing Rails site - ruby | fooobar.commysql order by query trying to randomize results with char_length pairs - mysqlparts of asynchronous httpwebrequest - c #How to block until a thread is returned to the pool? - multithreadingHow to map a dataset and a typed dataset using Automapper? - .netSQL Server 2000: Field Length in 1/3 (or 2/3) Records - sortingFirebug - Break on Error - d - undefined - jqueryStuck with MySQL and GROUP BY - mysqlWhat is called this user interface element? for iphone - objective-cAll Articles