C
Chris
Hi,
1) I find the notation for managed arrays in C++.NET very confusing :
Sometimes is it not necessary to use the pointer notation ==>
short pS2 __gc[] = new short __gc[MAX];
Sometimes it is !!! (aparently when declaring an array of managed types) ==>
String* pString[] = new String*[MAX];
Why this difference in notations ?
2) Then, I try to allocate an array of custom managed objects but can't get
the syntax right. I get a runtime error.
__gc class Date
{
public:
Date () {
m_mo = m_da = m_yr = 0;
}
void Date :: Display () {
Console::WriteLine("{0}/{1}/{2}", m_mo.ToString(), m_da.ToString(),
m_yr.ToString());
}
private:
int m_mo, m_da, m_yr;
};
void main()
{
Date pdate __gc[] = new Date __gc[MAX]; --> COMPILER ERROR
Date* pdate __gc[] = new Date* __gc[4]; --> OK BUT ....
pdate[0]->Display(); --> .... RUNTIME
ERROR
}
What is the correct use ?
Many thanks
Chris
1) I find the notation for managed arrays in C++.NET very confusing :
Sometimes is it not necessary to use the pointer notation ==>
short pS2 __gc[] = new short __gc[MAX];
Sometimes it is !!! (aparently when declaring an array of managed types) ==>
String* pString[] = new String*[MAX];
Why this difference in notations ?
2) Then, I try to allocate an array of custom managed objects but can't get
the syntax right. I get a runtime error.
__gc class Date
{
public:
Date () {
m_mo = m_da = m_yr = 0;
}
void Date :: Display () {
Console::WriteLine("{0}/{1}/{2}", m_mo.ToString(), m_da.ToString(),
m_yr.ToString());
}
private:
int m_mo, m_da, m_yr;
};
void main()
{
Date pdate __gc[] = new Date __gc[MAX]; --> COMPILER ERROR
Date* pdate __gc[] = new Date* __gc[4]; --> OK BUT ....
pdate[0]->Display(); --> .... RUNTIME
ERROR
}
What is the correct use ?
Many thanks
Chris