cannot access protected member declared in class ‘base’

by ixmx


#include "stdafx.h"

class base
{
protected:
	void method1()
	{
	}
};

class der1:public base
{
public:
	void method2(base * p)
	{
		p->method1(); //Error C2248: 'base::method1' :
//cannot access protected member declared in class 'base'
	}
};

int _tmain(int argc, _TCHAR* argv[])
{

	base *p1  = new base();

	der1 *d = new der1();

	d->method2(p1);

	return 0;
}

 
Advertisements