functor
April 27th, 2005, 04:48 PM
Heya!
I'm converting some unmanaged code into managed code. I've got several classes that I have created. The problem I'm running into occurs when I try and create a data member in one of my classes that is an array of another class I created. Everything worked fine when it was unmanaged, but now I'm getting an error on the array declaration: error C2691: 'hall' : invalid type for __gc array element
Here are 2 of my classes .h files:
game.h
-----------------
#pragma once
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
__gc class game
{
public:
game(void);
~game(void);
static char* gameNumber = new char[MAX_STRING_LENGTH];
static char* currentBooked = new char[MAX_STRING_LENGTH];
static char* lastReBooked = new char[MAX_STRING_LENGTH];
static char* printed = new char[MAX_STRING_LENGTH];
static char* transmitSales = new char[MAX_STRING_LENGTH];
static char* transmitSalesSuccess = new char[MAX_STRING_LENGTH];
static char* gameStatus = new char[MAX_STRING_LENGTH];
};
hall.h
-----------------
#pragma once
#include "game.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
__gc class hall
{
public:
hall(void);
~hall(void);
void getGames(void);
void getPrinted(char *, char *);
void getPreviousBooked(char *, char *);
void getTXSuccess(char *, char *);
void stringToCharArray(char *, String *);
static char* hallCode = new char[MAX_STRING_LENGTH];
static char* hallName = new char[MAX_STRING_LENGTH];
static char* stationID = new char[MAX_STRING_LENGTH];
static char* stationName = new char[MAX_STRING_LENGTH];
static char* hallStatus = new char[MAX_STRING_LENGTH];
game hallGames[MAX_GAMES_PER_HALL]; // THIS IS WHERE I GET THE ERROR!
int numGames;
};
I tried doing: game *hallGames = new game[MAX_GAMES_PER_HALL];
I also tried it with a static thrown infront. Nothing seems to work.
How do i properly declare an array of another class as a data member in a managed class?
I'm converting some unmanaged code into managed code. I've got several classes that I have created. The problem I'm running into occurs when I try and create a data member in one of my classes that is an array of another class I created. Everything worked fine when it was unmanaged, but now I'm getting an error on the array declaration: error C2691: 'hall' : invalid type for __gc array element
Here are 2 of my classes .h files:
game.h
-----------------
#pragma once
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
__gc class game
{
public:
game(void);
~game(void);
static char* gameNumber = new char[MAX_STRING_LENGTH];
static char* currentBooked = new char[MAX_STRING_LENGTH];
static char* lastReBooked = new char[MAX_STRING_LENGTH];
static char* printed = new char[MAX_STRING_LENGTH];
static char* transmitSales = new char[MAX_STRING_LENGTH];
static char* transmitSalesSuccess = new char[MAX_STRING_LENGTH];
static char* gameStatus = new char[MAX_STRING_LENGTH];
};
hall.h
-----------------
#pragma once
#include "game.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
__gc class hall
{
public:
hall(void);
~hall(void);
void getGames(void);
void getPrinted(char *, char *);
void getPreviousBooked(char *, char *);
void getTXSuccess(char *, char *);
void stringToCharArray(char *, String *);
static char* hallCode = new char[MAX_STRING_LENGTH];
static char* hallName = new char[MAX_STRING_LENGTH];
static char* stationID = new char[MAX_STRING_LENGTH];
static char* stationName = new char[MAX_STRING_LENGTH];
static char* hallStatus = new char[MAX_STRING_LENGTH];
game hallGames[MAX_GAMES_PER_HALL]; // THIS IS WHERE I GET THE ERROR!
int numGames;
};
I tried doing: game *hallGames = new game[MAX_GAMES_PER_HALL];
I also tried it with a static thrown infront. Nothing seems to work.
How do i properly declare an array of another class as a data member in a managed class?