Giter VIP home page Giter VIP logo

Показан перевод для запроса Не компилирует с абстрактными классами и Искать вместо этого перевод для Не компилируеться с абстрактными классами и It does not compile with abstract classes and boos 1.6 about hypodermic HOT 3 CLOSED

ybainier avatar ybainier commented on August 17, 2024
Показан перевод для запроса Не компилирует с абстрактными классами и Искать вместо этого перевод для Не компилируеться с абстрактными классами и It does not compile with abstract classes and boos 1.6

from hypodermic.

Comments (3)

ybainier avatar ybainier commented on August 17, 2024

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.

wodphoenix avatar wodphoenix commented on August 17, 2024

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.

ybainier avatar ybainier commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.