mirror of
https://github.com/boostorg/openmethod.git
synced 2026-01-20 04:42:21 +00:00
35 lines
759 B
C++
35 lines
759 B
C++
// Copyright (c) 2018-2025 Jean-Louis Leroy
|
|
// Distributed under the Boost Software License, Version 1.0. (See
|
|
// accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
// tag::content[]
|
|
// extensions.cpp
|
|
#include "animals.hpp"
|
|
|
|
using namespace boost::openmethod::aliases;
|
|
|
|
BOOST_OPENMETHOD_OVERRIDE(
|
|
meet, (virtual_ptr<Herbivore>, virtual_ptr<Carnivore>), std::string) {
|
|
return "run";
|
|
}
|
|
|
|
BOOST_OPENMETHOD_OVERRIDE(
|
|
meet, (virtual_ptr<Carnivore>, virtual_ptr<Herbivore>), std::string) {
|
|
return "hunt";
|
|
}
|
|
|
|
struct Tiger : Carnivore {};
|
|
|
|
BOOST_OPENMETHOD_CLASSES(Tiger, Carnivore);
|
|
|
|
extern "C" {
|
|
#ifdef _WIN32
|
|
__declspec(dllexport)
|
|
#endif
|
|
auto make_tiger() -> Animal* {
|
|
return new Tiger;
|
|
}
|
|
}
|
|
// end::content[]
|