Variables

I must work on two classes and every time I must bring the content of a variable from a class to another .

CAddPointView
CQuantDlg

These are the two classes

In CAddPointView I have got the variable "c_uni",and in CQuantDlg I need it

I try to write this in a function of CQuantDlg:

CAddPointView *p; // get a pointer to CAddPointView class
CString cu=p->c_uni;

But the program goes in error whi?
Can you help me?
[481 byte] By [elektroman] at [2007-11-18 13:41:45]
# 1 Re: Variables
CAddPointView *p; // get a pointer to CAddPointView class

This is a pointer to uninitialized memory, not a pointer to an instance of a CAddPointView class.

You likely want to do something like:

CAddPointView *p = GetPtrToTheViewClass();
CString cu=p->c_uni;

The implementation of GetPtrToTheViewClass is left to you.

Also - what is the type of CAddPointView::c_uni?
vicodin451 at 2007-11-11 2:09:10 >
# 2 Re: Variables
did you try to check your pointer with ASSERT_VALID?
propably you can reach anything with it.
pgrohs at 2007-11-11 2:10:21 >
# 3 Re: Variables
c_uni is a CString type
elektroman at 2007-11-11 2:11:22 >
# 4 Re: Variables
Did you try to use the new operator?
vcstarter at 2007-11-11 2:12:17 >
# 5 Re: Variables
Originally posted by vcstarter
Did you try to use the new operator?

I believe what vcstarter is getting at is that you could do something like:

CAddPointView *p = new CAddPointView;
CString cu=p->c_uni;
// ...
delete p;

Of course, this would imply that something has been done to put a worthy value into p->c_uni...
vicodin451 at 2007-11-11 2:13:16 >