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?

Edited 3 Years Ago by Reverend Jim: Fixed formatting

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!

Edited 3 Years Ago by happygeek: fixed formatting

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 ? :)

Comments
I appreciate your suggestion.
This article has been dead for over six months. Start a new discussion instead.