protected constructor
-
hi every one How can i create object of a class with protected constructor? i dont want drived it from base class. is it possible using friend class? Plz Help me
-
hi every one How can i create object of a class with protected constructor? i dont want drived it from base class. is it possible using friend class? Plz Help me
-
hi every one How can i create object of a class with protected constructor? i dont want drived it from base class. is it possible using friend class? Plz Help me
A public static method in the class can be used to create the object of the class. The caller can then use the static method to create an object of the class.
«_Superman_» I love work. It gives me something to do between weekends.
-
Yes.
Eg:
class base
{
protected :
base()
{
}
friend ami;
};class ami
{
public:
base obj;
};OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
i test it but i get this error: error C2248: 'CAsynlstn::CAsynlstn' : cannot access private member declared in class 'CAsynlstn' [path]: see declaration of 'CAsynlstn::CAsynlstn'
class CMyCtrl : public COleControl
{private:
friend class CAsynlstn;
CMyCtrl();
~CMyCtrl();
}//////////////////////////////////////////
class CAsynlstn : public CAsyncSocket
{private:
CAsynlstn(COleControl* pDlg);
virtual ~CAsynlstn();};
///////////////////////////////////////
//CMyCtrl.h
///////////////////////////////////////
public:
CAsynSvSk* m_pSrvrSock;
///////////////////////////////////////
//CMyCtrl.Cpp
///////////////////////////////////////m\_pLstnSock = new CAsynlstn(this) /\*error C2248: 'CAsynlstn::CAsynlstn' : cannot access private member declared in class 'CAsynlstn' \[path\]: see declaration of 'CAsynlstn::CAsynlstn'\*/
-
i test it but i get this error: error C2248: 'CAsynlstn::CAsynlstn' : cannot access private member declared in class 'CAsynlstn' [path]: see declaration of 'CAsynlstn::CAsynlstn'
class CMyCtrl : public COleControl
{private:
friend class CAsynlstn;
CMyCtrl();
~CMyCtrl();
}//////////////////////////////////////////
class CAsynlstn : public CAsyncSocket
{private:
CAsynlstn(COleControl* pDlg);
virtual ~CAsynlstn();};
///////////////////////////////////////
//CMyCtrl.h
///////////////////////////////////////
public:
CAsynSvSk* m_pSrvrSock;
///////////////////////////////////////
//CMyCtrl.Cpp
///////////////////////////////////////m\_pLstnSock = new CAsynlstn(this) /\*error C2248: 'CAsynlstn::CAsynlstn' : cannot access private member declared in class 'CAsynlstn' \[path\]: see declaration of 'CAsynlstn::CAsynlstn'\*/
class CAsynlstn : public CAsyncSocket
{private:
public:
CAsynlstn(COleControl* pDlg);
virtual ~CAsynlstn();}
m_pLstnSock = new CAsynlstn(this); If you are creating object straight like this it has to be public. btw, what are you trying to do with this?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
-
hi every one How can i create object of a class with protected constructor? i dont want drived it from base class. is it possible using friend class? Plz Help me
Here's a solution from Mr C++ himself[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
A public static method in the class can be used to create the object of the class. The caller can then use the static method to create an object of the class.
«_Superman_» I love work. It gives me something to do between weekends.
can you give me an example?
-
Here's a solution from Mr C++ himself[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
thanks Mr Stuart Dootson