Access violation problem
-
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concern -
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concernWhat are you trying to do? Can you show us a little bit more of your code?
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concernDefine your class B on top A. and see to that you've specified "protected" or "public" to your BOOL m_started;
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concernp_channel is an uninitialized pointer. Time to pick up the C++ book.
-- Broadcast simultaneously one year in the future
-
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concernHow to initialized p_channel?
WhiteSky
-
How to initialized p_channel?
WhiteSky
??whitesky?:~
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
p_channel is an uninitialized pointer. Time to pick up the C++ book.
-- Broadcast simultaneously one year in the future
the thing is that this p_channel is assigned a value in the construction of the class, meaning that the constructor is responsible for initializing this pointer so when i call p_channel->"whatever" it is supposed that it is already initialized
-
??whitesky?:~
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
Why:doh:
WhiteSky
-
hello, i have a 2 classes each have a couple of functions and variable the problem is: when i want to access a variable from class B inside a function in class A it come up with Unhandled Exception says: unhandled exception in "program name": 0xC0000005: Access Violation
class A { //////// B* p_channel; ///////// inline BOOL StartIVR(){ p_channel->m_started = TRUE; // error occur here} /////// } class B { ///////// BOOL m_started ; /////// }
also any other access to any member in class B will result with the same exception plz if anybody have any idea abt what's goin' on with this code, feel free to tell me :=) thnx alot for ur time and concernYes guys i was wrong i was passing the pointer to the constructor without initializing it this is wierd, how did i forget to initialize a pointer. thnx 4 u help it was really useful. :=)
-
Why:doh:
WhiteSky
Your post looked like you are asking how to initialize a pointer ;P :-D
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
the thing is that this p_channel is assigned a value in the construction of the class, meaning that the constructor is responsible for initializing this pointer so when i call p_channel->"whatever" it is supposed that it is already initialized
what?? you say
B* p_channel
then how can it be ?You should've putB* p_channel=new B;
Even I didn't notice it.
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
Your post looked like you are asking how to initialize a pointer ;P :-D
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
wow really:-D
WhiteSky