[.net] can't create an array of managed objects

Started by
5 comments, last by exorcist_bob 18 years ago
Why doesn't the following work? System::Double Something[5]; Thanks, exorcist_bob
Advertisement
I think the syntax might be wrong.
I'm not sure though since I haven't programmed in c++ for quite a while.
Try something like this:

System::Double[] Something = new System::Double[5];
What is the error message?

I believe you have to use a pointer. At least in C++ 1.1 I did.

System::Double * array[] = new Double[6];
In what language?

C# looks this way:
double[] array = new double[10];
System::Double Something[] = new System::Double[5];

None of that is really helping me. Here is a more direct example:

ref class SavingsInterestRatesAndFees{public:	System::String^ Name;	System::Double InterestRate[];	System::Double PercentYieldRate[5];	System::Double MinimumOpeningDeposit;	System::Double MinimumMaintainedBalance;	System::Double MonthlyServiceFee;	System::Double MinimumRequiredToWaiveServiceFee;	SavingsInterestRatesAndFees();};SavingsInterestRatesAndFees::SavingsInterestRatesAndFees(){	InterestRate = gcnew System::Double[5];};


I keep getting this error:
DBEngine.h(114) : error C4368: cannot define 'InterestRate' as a member of managed 'SavingsInterestRatesAndFees': mixed types are not supported

Thanks for all your help,
exorcist_bob
Finally! I figured it out! For your reference, you have to implement some kind of declaration like this:

array<DataType^>^Variable;

Thanks for all your help, r++!

This topic is closed to new replies.

Advertisement