[RESOLVED] Forms SingleTon VC++2010?
Hi,
Iam using the below code for forms singleton in c#.. When I convert it to VC++ its giving error..
c# code
======
private static Form2 _instance = null;
public static Form2 GetForm (bool IsMDIChild, Form1 frm)
{
if (_instance == null)
_instance = new Form2();
if (_instance.IsDisposed)
_instance = new Form2();
if (IsMDIChild)
_instance.MdiParent = frm;
return _instance;
}
I convert it like a below.. to vc++2010
===========================
public: static Form2^ Form2::_instance = nullptr;
public: static Form2^ Form2::GetForm(bool IsMDIChild, Form1^ MyInstFrm) {
if (_instance == nullptr)
_instance = gcnew Form2();
if (_instance->IsDisposed)
_instance = gcnew Form2();
if (IsMDIChild)
_instance->MdiParent = MyInstFrm;
return _instance;
}
But its giving below error
01. Error c2061 Syntax error : Identifier 'Form1'
Thanks
Re: Forms SingleTon VC++2010?
Perhaps you forgot to #include "Form1.h", so Form1 isn't defined at that point?
EDIT: I noticed that actually you're not using any members specific to Form1 at all anyway in that code, so you may as well change the type of that parameter to Form ^, so the include wouldn't be needed. You could still pass an instance of any class derived from Form to that parameter.
Please use code tags when posting code.
Re: Forms SingleTon VC++2010?
My Heartiest Thanks To ERI...