jipeval
August 1st, 2005, 05:50 PM
Hello,
I am new to managed C++ and I am trying to figure out how to pass a String in a function member of a managed object:
Here is my code:
private: System::Void menuItem4_Click(System::Object * sender, System::EventArgs * e)
{
// INITIATE
CCG *BCG=new CCG();
String* STR;
if( this->openFileDialog1->ShowDialog() == DialogResult::Cancel )
{
MessageBox::Show(S"No file loaded.");
}
STR=this->openFileDialog1->get_FileName();
BCG->Read_E(STR,10,400);
}
Read_E is defined as follow in .h file:
public __gc class CCG
{
public:
void Read_E(String *FileName, long lStart, long lDataLenght);
CCG(void);
~CCG(void);
}
in my .cpp file:
void CCG::Read_E(String *strFileName, long lStart, long lDataLenght)
{......}
The code debugs fine but the strFilename is out of scope in my CCG::Read_E....
I spent a lot of time trying to figure this out.. if someone could help me understanding why my strFileName becomes out of scope ...
unmanaged JP...
I am new to managed C++ and I am trying to figure out how to pass a String in a function member of a managed object:
Here is my code:
private: System::Void menuItem4_Click(System::Object * sender, System::EventArgs * e)
{
// INITIATE
CCG *BCG=new CCG();
String* STR;
if( this->openFileDialog1->ShowDialog() == DialogResult::Cancel )
{
MessageBox::Show(S"No file loaded.");
}
STR=this->openFileDialog1->get_FileName();
BCG->Read_E(STR,10,400);
}
Read_E is defined as follow in .h file:
public __gc class CCG
{
public:
void Read_E(String *FileName, long lStart, long lDataLenght);
CCG(void);
~CCG(void);
}
in my .cpp file:
void CCG::Read_E(String *strFileName, long lStart, long lDataLenght)
{......}
The code debugs fine but the strFilename is out of scope in my CCG::Read_E....
I spent a lot of time trying to figure this out.. if someone could help me understanding why my strFileName becomes out of scope ...
unmanaged JP...