Re: VS6 debug mode error with pointer declared in class




"David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
news:uDeaazx1IHA.4848@xxxxxxxxxxxxxxxxxxxxxxx
Daniel Lohmann wrote:
Hi

I get an access violation crash with declaring the pointer in the class
constructor when I run in Debug mode but it seems to run ok in Release
mode. It is not clear what I am doing wrong.

Example code:

class CfooDlg : public CDialog

{

// Construction

public:

CfooDlg(CWnd* pParent = NULL); // standard constructor

int * m_pMyPointer;

// Dialog Data

Daniel:

Presumably you are using this pointer in some way?

And what do you mean "declaring the pointer in the class constructor" ?
Your posted code just declares the pointer as a public member variable.

BTW, you should post Visual C++ questions in one of the VC newsgroups:

microsoft.public.vc.language
microsoft.public.vc.mfc

--
David Wilkinson
Visual C++ MVP

David:
Sorry I didn't get back to you sooner - ISP troubles.

Presumably you are using this pointer in some way?
I will be using the pointer with dynamic memory storage.

And what do you mean "declaring the pointer in the class constructor" ?
Your posted code just declares the pointer as a public member variable.
Sorry about the semantics.

BTW, you should post Visual C++ questions in one of the VC newsgroups:
I thought about posting in a VC++ newsgroup but since it seemed to be more a
VS question (debug mode error versus release mode success) I took a chance
and posted here. I didn't want to cross post. Sorry about offending anyone.

Since the original post, the problem has been resolved. Unfortunately I
can't really say what I actually did to fix it.
Daniel



.



Relevant Pages

  • Re: VS6 debug mode error with pointer declared in class
    ... I get an access violation crash with declaring the pointer in the class constructor when I run in Debug mode but it seems to run ok in Release mode. ...
    (microsoft.public.vstudio.general)
  • VS6 debug mode error with pointer declared in class
    ... I get an access violation crash with declaring the pointer in the class ... constructor when I run in Debug mode but it seems to run ok in Release mode. ... class CfooDlg: public CDialog ...
    (microsoft.public.vstudio.general)
  • Re: Question about arrays in objects
    ... >>I want to create a 2d array as an object member. ... > handled in the constructor, you just can't use a plain old array. ... > that is where using a pointer would come in. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Strange EAccessViolation which I cannot figure out...
    ... where in your code you are freeing and setting it to NIL to then later ... The proper way is to always create it in the constructor or, ... type cast around this returned value as a pointer to a pchar string. ...
    (comp.lang.pascal.delphi.misc)
  • Re: C++ 101 dumb question
    ... Yep I do comprehend the difference between a pointer and the data it ... If you have a CMyClass a; ... What does the signature of a copy constructor look like? ... Its action is to copy the data members of the class, ...
    (microsoft.public.vc.language)

Loading