how to pass a structure as reference. [modified]
-
Hi all, i am facing a problem while passing a reference as structure from one class member function to another class member function. ie) i will pass a struct as input from Class A member function to Class B member function. There in Class B member function it has to fill the Structure and give me the filled structure in Class A member function. Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function. please this very very urgent for me. -- modified at 1:57 Sunday 5th August, 2007
Uday kiran
-
Hi all, i am facing a problem while passing a reference as structure from one class member function to another class member function. ie) i will pass a struct as input from Class A member function to Class B member function. There in Class B member function it has to fill the Structure and give me the filled structure in Class A member function. Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function. please this very very urgent for me. -- modified at 1:57 Sunday 5th August, 2007
Uday kiran
Can you show an example of the method declaration and how you were calling it? What exactly is the problem that's occurring? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi all, i am facing a problem while passing a reference as structure from one class member function to another class member function. ie) i will pass a struct as input from Class A member function to Class B member function. There in Class B member function it has to fill the Structure and give me the filled structure in Class A member function. Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function. please this very very urgent for me. -- modified at 1:57 Sunday 5th August, 2007
Uday kiran
-
Hi all, i am facing a problem while passing a reference as structure from one class member function to another class member function. ie) i will pass a struct as input from Class A member function to Class B member function. There in Class B member function it has to fill the Structure and give me the filled structure in Class A member function. Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function. please this very very urgent for me. -- modified at 1:57 Sunday 5th August, 2007
Uday kiran
/* Not dialog based but you should get what your looking for here. */ #include "stdafx.h" #include typedef struct { int nKey; int nSize; } MY_STRUCTURE; class CBar { public: CBar::CBar() {} CBar::~CBar() {} void CBar::DoSomething(MY_STRUCTURE& myStructure) { // Modify the structure myStructure.nKey=45; myStructure.nSize=99; } }; class CFoo { public: CFoo() { Start(); } ~CFoo() {} void Start() { CBar bar; MY_STRUCTURE someStructure={0}; printf("BEFORE: nKey = %d, nSize = %d\n", someStructure.nKey,someStructure.nSize); bar.DoSomething(someStructure); printf("AFTER: nKey = %d, nSize = %d\n", someStructure.nKey,someStructure.nSize); } }; int main(int argc, char* argv[]) { CFoo foo; return 0; }
-
Hi all, i am facing a problem while passing a reference as structure from one class member function to another class member function. ie) i will pass a struct as input from Class A member function to Class B member function. There in Class B member function it has to fill the Structure and give me the filled structure in Class A member function. Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function. please this very very urgent for me. -- modified at 1:57 Sunday 5th August, 2007
Uday kiran
uday kiran janaswamy wrote:
Note: this i am facing in vc++. i am having two dialog classes where i have to send this reference variable from first class member function to second Class member function.
But what is the problem!.. hang, value is not updated or something else!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief
-
/* Not dialog based but you should get what your looking for here. */ #include "stdafx.h" #include typedef struct { int nKey; int nSize; } MY_STRUCTURE; class CBar { public: CBar::CBar() {} CBar::~CBar() {} void CBar::DoSomething(MY_STRUCTURE& myStructure) { // Modify the structure myStructure.nKey=45; myStructure.nSize=99; } }; class CFoo { public: CFoo() { Start(); } ~CFoo() {} void Start() { CBar bar; MY_STRUCTURE someStructure={0}; printf("BEFORE: nKey = %d, nSize = %d\n", someStructure.nKey,someStructure.nSize); bar.DoSomething(someStructure); printf("AFTER: nKey = %d, nSize = %d\n", someStructure.nKey,someStructure.nSize); } }; int main(int argc, char* argv[]) { CFoo foo; return 0; }
hi, Yes, i cought for this only and you have showed me path. Thanks a Lot it exaclty what the problem i facing.
Uday kiran
-
Either you pass the member function a pointer to the structure (&structvar), or make the receiving function accept the argument by reference (classname::member(structtype & structvar).
hi, Thanks a Lot I get it.
Uday kiran