P
Peter Oliphant
Below are the definitions of two classes. VList creates two static integer
arrays (v_0, v_1), creates an array of pointers to these arrays (vlist), and
has a public method to return a pointer to the corresponding integer array
based on its index into vlist (Element( index )) .
MyClass contains an instance of VList, and then tries to call Element(1) and
get a pointer to the appropriate integer list (v_1). But what comes out the
debugger says the result is an undefined variable.
What am I doing wrong? Alternately I'd like to return the copied values of
the appropriate int array to an external int array (in contrast to returning
a pointer to the internal int array), but not sure how to do this via a
return from a subroutine.
Note the 'static' aspect to much of VList.
Thanx in advance for any help...
[==P==]
//----------------------------------------------------
#typedef array<int> Int_Array ;
#typedef array<Int_Array> Int_Array_Array ;
//----------------------------------------------------
ref class VList
{
public:
VList(){}
~VList() {}
public:
static Int_Array^ Element( int i )
{
return vlist ;
}
private:
static Int_Array_Array^ vlist = gcnew Int_Array_Array(2)
{
v_0, v_1
} ;
static Int_Array^ v_0 = gcnew Int_Array(2){ 0x01, 0x02 } ;
static Int_Array^ v_1 = gcnew Int_Array(2){ 0x03, 0x04 } ;
} ;
//-------------------------------------------------------
ref class myClass
{
public:
myClass(){}
~myClass(){}
void Sub()
{
Int_Array^ info = m_Vlist.Element( 1 ) ;
int x = info[0] ; // error here - debugger says 'info' is an 'undefined
variable'!
}
private:
VList m_VList ;
} ;
//-------------------------------------------------------------
arrays (v_0, v_1), creates an array of pointers to these arrays (vlist), and
has a public method to return a pointer to the corresponding integer array
based on its index into vlist (Element( index )) .
MyClass contains an instance of VList, and then tries to call Element(1) and
get a pointer to the appropriate integer list (v_1). But what comes out the
debugger says the result is an undefined variable.
What am I doing wrong? Alternately I'd like to return the copied values of
the appropriate int array to an external int array (in contrast to returning
a pointer to the internal int array), but not sure how to do this via a
return from a subroutine.
Note the 'static' aspect to much of VList.
Thanx in advance for any help...
[==P==]
//----------------------------------------------------
#typedef array<int> Int_Array ;
#typedef array<Int_Array> Int_Array_Array ;
//----------------------------------------------------
ref class VList
{
public:
VList(){}
~VList() {}
public:
static Int_Array^ Element( int i )
{
return vlist ;
}
private:
static Int_Array_Array^ vlist = gcnew Int_Array_Array(2)
{
v_0, v_1
} ;
static Int_Array^ v_0 = gcnew Int_Array(2){ 0x01, 0x02 } ;
static Int_Array^ v_1 = gcnew Int_Array(2){ 0x03, 0x04 } ;
} ;
//-------------------------------------------------------
ref class myClass
{
public:
myClass(){}
~myClass(){}
void Sub()
{
Int_Array^ info = m_Vlist.Element( 1 ) ;
int x = info[0] ; // error here - debugger says 'info' is an 'undefined
variable'!
}
private:
VList m_VList ;
} ;
//-------------------------------------------------------------