I
itaj sherman
The following does not compile on my VC6. Is it standard?
#include <iostream>
class Base
{
public:
explicit Base()
{
std::cout << "Base:ctor()" << "\n";
}
};
class Scope
{
public:
typedef Base BaseInScope;
};
class Derived:
public Scope::BaseInScope
{
public:
explicit Derived()
:
Scope::BaseInScope()
{
std::cout << "Derived:ctor()" << "\n";
}
};
D:\code\Test\Test\Test.cpp(39) : error C2614: 'Derived' : illegal
member initialization: 'BaseInScope' is not a base or member
The following fixes the problem:
class Derived:
public Scope::BaseInScope
{
public:
typedef Scope::BaseInScope MyBase
explicit Derived()
:
MyBase()
{
std::cout << "Derived:ctor()" << "\n";
}
};
and also:
class Derived:
public Scope::BaseInScope
{
public:
explicit Derived()
:
Base()
{
std::cout << "Derived:ctor()" << "\n";
}
};
#include <iostream>
class Base
{
public:
explicit Base()
{
std::cout << "Base:ctor()" << "\n";
}
};
class Scope
{
public:
typedef Base BaseInScope;
};
class Derived:
public Scope::BaseInScope
{
public:
explicit Derived()
:
Scope::BaseInScope()
{
std::cout << "Derived:ctor()" << "\n";
}
};
D:\code\Test\Test\Test.cpp(39) : error C2614: 'Derived' : illegal
member initialization: 'BaseInScope' is not a base or member
The following fixes the problem:
class Derived:
public Scope::BaseInScope
{
public:
typedef Scope::BaseInScope MyBase
explicit Derived()
:
MyBase()
{
std::cout << "Derived:ctor()" << "\n";
}
};
and also:
class Derived:
public Scope::BaseInScope
{
public:
explicit Derived()
:
Base()
{
std::cout << "Derived:ctor()" << "\n";
}
};