Hi guys,
I need your help. I am trying to build a Win32 project under Windows XP using managed C++ 2005 Express Edition. I have a bit of trouble with the errors. I am trying to linked the code to the class library, but i couldn't be able to find the solutions to get rid of the errors.
error C2227: left of '->Decrypt' must point to class/struct/union/generic type
The error are linked to the line:
Code:if (plainText->Text == enc->Decrypt(key, "key123456"))
And I also get another error using with the same line:
error C3845: 'myapplication::Form1::key': only static data members can be initialized inside a ref class or value type
Code:String ^key = "MoY3fOB+LbiQy6V3R35FASSmy";
here's the current code:
I have input the "include class.h" on the top of the header, but it doesn't help me to get correct the errors. And also I cannot understand the second error I have got which I created the name of the string.Code:#pragma once #include "Class1.h" namespace myapplication { using namespace System; using namespace System::Collections::Generic; using namespace System::Text; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form1() { if (components) { delete components; } } internal: System::Windows::Forms::Label^ label2; protected: internal: System::Windows::Forms::Button^ Button1; internal: System::Windows::Forms::TextBox^ plainText; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->label2 = (gcnew System::Windows::Forms::Label()); this->Button1 = (gcnew System::Windows::Forms::Button()); this->plainText = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(24, 46); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(302, 13); this->label2->TabIndex = 6; this->label2->Text = L"Do you know what the password is\? if so please enter it here..."; // // Button1 // this->Button1->Location = System::Drawing::Point(122, 101); this->Button1->Name = L"Button1"; this->Button1->Size = System::Drawing::Size(96, 34); this->Button1->TabIndex = 5; this->Button1->Text = L"Confirm password!"; this->Button1->UseVisualStyleBackColor = true; this->Button1->Click += gcnew System::EventHandler(this, &Form1::Button1_Click); // // plainText // this->plainText->Location = System::Drawing::Point(27, 65); this->plainText->Name = L"plainText"; this->plainText->Size = System::Drawing::Size(292, 20); this->plainText->TabIndex = 4; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(341, 162); this->Controls->Add(this->label2); this->Controls->Add(this->Button1); this->Controls->Add(this->plainText); this->MaximizeBox = false; this->MinimizeBox = false; this->Name = L"Form1"; this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Hide; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->Text = L"myapplication"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion myapplication ::Class1 ^enc(); myapplication ::Class1 ^dec(); String ^key = "MoY3fOB+LbiQy6V3R35FASSmy"; private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { this->Select(); } private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e) { if (plainText->Text == enc->Decrypt(key, "key123456")) { MessageBox::Show("the password is correct!"); } else { MessageBox::Show("the password is incorrect"); } } }; }
Can somebody please tell me how to fix those errors?
Any advice would be much appreciated.
Thanks in advance.



LinkBack URL
About LinkBacks



