Created
December 27, 2017 10:18
-
-
Save xaizek/8d0407d5fb8ced3145188dce24938788 to your computer and use it in GitHub Desktop.
Class method clash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "header.hpp" | |
#include <iostream> | |
class B : public A | |
{ | |
void f() | |
{ | |
doIt(); | |
} | |
static void doIt() | |
{ | |
std::cout << "first" << std::endl; | |
} | |
}; | |
A *makeA1() | |
{ | |
return new B(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef HEADER_HPP__ | |
#define HEADER_HPP__ | |
class A | |
{ | |
public: | |
virtual void f() = 0; | |
}; | |
A *makeA1(); | |
A *makeA2(); | |
#endif // HEADER_HPP__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "header.hpp" | |
#include <iostream> | |
int | |
main(int argc, char *argv[]) | |
{ | |
std::cout << "A1:" << std::endl; | |
makeA1()->f(); | |
std::cout << "A2:" << std::endl; | |
makeA2()->f(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "header.hpp" | |
#include <iostream> | |
class B : public A | |
{ | |
void f() | |
{ | |
doIt(); | |
} | |
static void doIt() | |
{ | |
std::cout << "second" << std::endl; | |
} | |
}; | |
A *makeA2() | |
{ | |
return new B(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment