Please explain, if I have a virtual method in the base class and I redefine it in the derivative, should the addresses of these methods coincide? I have a base class Book. It contains the virtual function Show ():
virtual void Show() { showISBN(); showAuthor(); showTitle(); } There is a derived class CardFile, in which I override Show ():
void Show() override { Book::Show(); cout << "Number of refuge: " << refugeNumber << endl; cout << "Stock: " << stock << endl; } Next, in the console, I display the addresses of the methods in this way:
printf("Book::Show -- %p\n", &Book::Show); printf("CardFile::Show -- %p\n", &CardFile::Show); But for some reason I get different values. So it should be?
%p. This is usually a 3 times larger structure than a normal pointer. So its contents should be printed byte-sizeof(&Book::Show)bytes. - VTT