Comments (3)
Hi,
regarding your sample, I think you are not writing C++, therefore the error you get is not related to Hypodermic. You should write something like this instead:
class A
{
public:
virtual ~A() {}
virtual void method1() = 0;
};
class B : public A
{
public:
void method1() override {}
};
Hypodermic::ContainerBuilder builder;
builder.registerType< B >().as< A >();
auto container = builder.build();
auto instanceOfBWithStaticTypeA = container->resolve< A >();
instanceOfBWithStaticTypeA->method1();
Cheers
from hypodermic.
Sorry. Editor transformed template parameters
`#include "Hypodermic/ContainerBuilder.h"
#include "Hypodermic/Container.h"
class A
{
public:
virtual void method1()abstract;
};
class B:public A
{
public:
void method1() override
{
}
};
int main()
{
Hypodermic::ContainerBuilder builder;
builder.registerType< B >().as< A >();
auto container = builder.build();
container->resolve()->method1();
return 0;
}
`
I have done as you have in the example. But I can not understand why it does not work
from hypodermic.
I don't know if non native C++ is supported. Have a look at both stackoverflow and isocpp for further C++ documentation.
from hypodermic.
Related Issues (20)
- GUN C++ 4.7.3 Compiler error HOT 1
- Resolve other than shared_ptr (e.g. unique_ptr) HOT 5
- Current syntax for register factory with arguments HOT 5
- Pass parameters to register type HOT 1
- Resolve a chain of instantiate of explicit dependencies name?
- Compile errors: multiple definition of boost::*
- static assertion failed: TArg should be a complete type HOT 5
- [FeatureRequest] Fluent lifetime management HOT 1
- Autowiring of factory methods HOT 2
- Question: register two interfaces for same concrete class HOT 2
- Fail to build in window boost1.7 gcc9
- Bug: interface is resolved twice from nested container if they are added as both .as<interface>() and .asSelf() HOT 2
- Bug: singleInstance not working as expected when resolving from nested containers HOT 2
- How to inject a factory for named instances? HOT 3
- Is it possible to specify the dependency explicitly while resolving HOT 4
- Issue when resolving same types in different shared libraries HOT 1
- ContainerBuilder doesn't have a virtual destructor HOT 1
- Hypodermic 2.5.3 won't link with Boost
- Is there a version without boost HOT 5
- Alternatives to `std::make_shared` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hypodermic.