I have a following code

struct A { 
        int x;
A(int i) : x(i) {}
        virtual void a() {};
};

struct B: virtual A {
    B() : A(0) {}
    virtual void a(){} 
};

struct C: A, virtual B 
{
    virtual void a(){} 
    virtual void c(){}
};

The following code fails during the compilation
I add the C constructor C():A(1){} but the compilation still fails ...
Can somebody explain me what is the problem and how can I solve it?

Welcome bel050,
It would be virtual A.

struct C: virtual  A, virtual B
{
    C(): A(1) {}
   virtual void a(){}
   virtual void c(){}
};

Use code tags. Source code must be surrounded with code tags.
For example,

[CODE=C++] ... statements..

[/code]

I want the A to be non-virtual Base!

struct C: B {}

Use code tags. Source code must be surrounded with code tags.
For example,

[CODE=C++] ... statements..

[/code]

You're wrong, it should be:

[CODE=cplusplus] ... statements..

[/code]

Here's the difference:

#include <iostream>

using namespace std;

int main(){
    cout << "hai!";
}
#include <iostream>

using namespace std;

int main(){
    cout << "hai!";
}

See the difference in syntax-highlighting ? :)

commented: I appreciate your suggestion. +7

Thanks niek_e,
Yes, I got it. Thanks a lot for your cooperation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.