M
marco_segurini
Hi,
the following sample code shows a compiler error I get trying to build
some old code with the last CL compiler (vers 13.10.3077):
//----- begin
#include <iostream>
namespace ns
{
class base
{
public:
base() {}
virtual ~base() {}
protected:
void Call() { std::cout << "OK" << std::endl; }
};
class derived : public base
{
public:
void Start()
{
typedef void (ns::base::* typeCall)(void);
typeCall fnCall;
fnCall = &ns::base::Call; // this is the line # 21
(this->*fnCall)();
}
};
}
int main()
{
ns::derived d;
d.Start();
return 0;
}
//----- end
I get the following compiler message error at line 21:
main.cpp(21): error C2248: 'ns::base::Call' : cannot access protected
member declared in class 'ns::base'
Workaround: if I remove the ampersand all works fine.
I like to know if the line # 21 is really illegal.
thanks.
Marco.
the following sample code shows a compiler error I get trying to build
some old code with the last CL compiler (vers 13.10.3077):
//----- begin
#include <iostream>
namespace ns
{
class base
{
public:
base() {}
virtual ~base() {}
protected:
void Call() { std::cout << "OK" << std::endl; }
};
class derived : public base
{
public:
void Start()
{
typedef void (ns::base::* typeCall)(void);
typeCall fnCall;
fnCall = &ns::base::Call; // this is the line # 21
(this->*fnCall)();
}
};
}
int main()
{
ns::derived d;
d.Start();
return 0;
}
//----- end
I get the following compiler message error at line 21:
main.cpp(21): error C2248: 'ns::base::Call' : cannot access protected
member declared in class 'ns::base'
Workaround: if I remove the ampersand all works fine.
I like to know if the line # 21 is really illegal.
thanks.
Marco.