A
Armin Zingler
Hi,
how can I translate this VB code to managed C++? Note that the base class'
constructor is not called inside C2.New(i), neither implicitly nor
explicitly. In a constructor, it is valid to call an overloaded constructor
as the first statement instead of calling the base class' constructor. I
don't know the correct syntax in C++.
Class C1
Sub New(ByVal i As Integer)
End Sub
End Class
Class C2
Inherits C1
Sub New(ByVal i As Integer, ByVal j As Integer)
MyBase.New(i)
End Sub
Sub New(ByVal i As Integer)
MyClass.New(i, 0)
End Sub
End Class
My current version is:
ref class C1
{
public:
C1(int i)
{
}
};
ref class C2: C1
{
public:
C2 (int i, int j): C1(i)
{
};
C2 (int i) // C2512: 'C1': no appropriate
// default constructor available
{
C2(i, 0);
}
};
See C2512 inline. I've tried to change it to
C2 (int i): C2 (i,0)
{
}
but that's not the correct syntax, too. So, how is it done correctly?
Armin
how can I translate this VB code to managed C++? Note that the base class'
constructor is not called inside C2.New(i), neither implicitly nor
explicitly. In a constructor, it is valid to call an overloaded constructor
as the first statement instead of calling the base class' constructor. I
don't know the correct syntax in C++.
Class C1
Sub New(ByVal i As Integer)
End Sub
End Class
Class C2
Inherits C1
Sub New(ByVal i As Integer, ByVal j As Integer)
MyBase.New(i)
End Sub
Sub New(ByVal i As Integer)
MyClass.New(i, 0)
End Sub
End Class
My current version is:
ref class C1
{
public:
C1(int i)
{
}
};
ref class C2: C1
{
public:
C2 (int i, int j): C1(i)
{
};
C2 (int i) // C2512: 'C1': no appropriate
// default constructor available
{
C2(i, 0);
}
};
See C2512 inline. I've tried to change it to
C2 (int i): C2 (i,0)
{
}
but that's not the correct syntax, too. So, how is it done correctly?
Armin