Nov 12, 2012 at 6:38am UTC
Hi this is my program and i do have error number C2227 andI don't know how to fix it thank you.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
double investment = Convert::ToDouble (Investment->Text);
double interest = Convert::ToDouble (interest->Text);
double numberofyears = Convert::ToDouble (numberofyears->Text);
double conversions = Convert::ToDouble (conversions->Text);
double payment;
payment = investment + interest + numberofyears + conversions;
totalpayment->Text = Convert :: ToString(payment);
}
Form1.h(145): error C2227: left of '->Text' must point to class/struct/union/generic type
1> type is 'double'
Nov 12, 2012 at 6:53am UTC
Hi, andrewsaad !!
Welcome to the cPlusPlus forum
Form1.h(145): error C2227: left of '->Text' must point to class/struct/union/generic type
This error causes when the variable (totalpayment) is missing (not defined) or wrong type (not one of these types : class/struct/union/generic) (totalpayment or Text)
But, what is your compiler? And, can you give your
full source class please?
When you post the code, please always use code format tags - the
<> button on the right.
Hope all goes well.
Last edited on Nov 12, 2012 at 7:01am UTC
Nov 12, 2012 at 7:43am UTC
Firstly always use code tags - the <> button on the right
The error says that the variable to the left of the -> must be a pointer. In your case:
double investment = Convert::ToDouble (Investment->Text);
Investment is not a pointer, more over it is only a double, not a class object, or a struct. So there is no member to point to.
The error is pretty clear.
You have multiple examples of the same error.
There must be some other object that has the info you want inside it. You will need to pass this object to your function.
HTH
Nov 12, 2012 at 9:54am UTC
FYI - This is not C++, it's C++/CLI which is a Microsoft .NET language.