| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Passing String in function issue
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... |
|
#2
|
||||
|
||||
|
Re: Passing String in function issue
What do you mean with: "It goes out of scope"? It shall not go out of scope... Try to Copy() the string.
Best Regards, Florian
__________________
I am not offering technical guidiance via email or IM Come on share your photo with us! CG members photo album! Use the Code Tags! |
|
#3
|
|||
|
|||
|
Re: Passing String in function issue
That was helpful....
actually the passed string pointer was working fine I could copy the string but somehow I could not see the content of the string in the Watch window... strFileName was refered as out of scope.(which does not make sense) ... must be an issue with this feature of the .net studio. I wrote another similar function in the same class and it was working fine ... still, I do not understand what went wrong on this previous function! |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|