2014-04-26 2 views
0

인터넷에이 오류가 있음을 알리는 메시지가 표시됩니다. 어딘가에 있지만 내가 알 수있는 한, 나는 그 오류가 없다. 이 코드는 사용자가 목록에 이미있는 경우에도 단어를 추가 할 것인지 물어보고 이에 따라 입력에 응답합니다. 나는 C + +로 평균하지만 GUI에 익숙하지 않기 때문에 모든 시스템 키워드에 익숙하지 않습니다. Visual Studio 2010을 사용하고 있습니다. 오류 및 헤더 파일이 포함 된 코드를 알려 드리겠습니다. 나는이 메시지가 오류 C2143C2143 시스템 문자열 오류

#pragma once 
    #include "Generator.h" 
    #include <msclr/marshal_cppstd.h> 

    namespace GUI_PackProject { 

    using namespace System; 
    using namespace System::ComponentModel; 
    using namespace System::Collections; 
    using namespace System::Windows::Forms; 
    using namespace System::Data; 
    using namespace System::Drawing; 
    using namespace msclr::interop; 

    /// <summary> 
    /// Summary for AddName 
    /// </summary> 
    public ref class AddName : public System::Windows::Forms::Form 
    { 
    public: 
     AddName(void) 
     { 
      InitializeComponent(); 
      // 
      //TODO: Add the constructor code here 
      // 
     } 

    protected: 
     /// <summary> 
     /// Clean up any resources being used. 
     /// </summary> 
     ~AddName() 
     { 
      if (components) 
      { 
       delete components; 
      } 
     } 
    private: System::Windows::Forms::CheckBox^ FNCheckBox; 
    private: System::Windows::Forms::CheckBox^ LNCheckBox; 
    private: System::Windows::Forms::TextBox^ NameInput; 
    protected: 


    internal: System::Windows::Forms::Label^ UserInstruction; 
    private: System::Windows::Forms::Button^ btnAdd; 
    internal: 
    private: 

    protected: 

    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->FNCheckBox = (gcnew System::Windows::Forms::CheckBox()); 
      this->LNCheckBox = (gcnew System::Windows::Forms::CheckBox()); 
      this->NameInput = (gcnew System::Windows::Forms::TextBox()); 
      this->UserInstruction = (gcnew System::Windows::Forms::Label()); 
      this->btnAdd = (gcnew System::Windows::Forms::Button()); 
      this->SuspendLayout(); 
      // 
      // FNCheckBox 
      // 
      this->FNCheckBox->AutoSize = true; 
      this->FNCheckBox->Location = System::Drawing::Point(122, 83); 
      this->FNCheckBox->Name = L"FNCheckBox"; 
      this->FNCheckBox->Size = System::Drawing::Size(76, 17); 
      this->FNCheckBox->TabIndex = 0; 
      this->FNCheckBox->Text = L"First Name"; 
      this->FNCheckBox->UseVisualStyleBackColor = true; 
      // 
      // LNCheckBox 
      // 
      this->LNCheckBox->AutoSize = true; 
      this->LNCheckBox->Location = System::Drawing::Point(121, 106); 
      this->LNCheckBox->Name = L"LNCheckBox"; 
      this->LNCheckBox->Size = System::Drawing::Size(77, 17); 
      this->LNCheckBox->TabIndex = 1; 
      this->LNCheckBox->Text = L"Last Name"; 
      this->LNCheckBox->UseVisualStyleBackColor = true; 
      // 
      // NameInput 
      // 
      this->NameInput->Location = System::Drawing::Point(122, 57); 
      this->NameInput->Name = L"NameInput"; 
      this->NameInput->Size = System::Drawing::Size(100, 20); 
      this->NameInput->TabIndex = 2; 
      // 
      // UserInstruction 
      // 
      this->UserInstruction->AutoSize = true; 
      this->UserInstruction->Location = System::Drawing::Point(53, 60); 
      this->UserInstruction->Name = L"UserInstruction"; 
      this->UserInstruction->Size = System::Drawing::Size(63, 13); 
      this->UserInstruction->TabIndex = 3; 
      this->UserInstruction->Text = L"New Name:"; 
      // 
      // btnAdd 
      // 
      this->btnAdd->Location = System::Drawing::Point(104, 149); 
      this->btnAdd->Name = L"btnAdd"; 
      this->btnAdd->Size = System::Drawing::Size(75, 23); 
      this->btnAdd->TabIndex = 4; 
      this->btnAdd->Text = L"Add!"; 
      this->btnAdd->UseVisualStyleBackColor = true; 
      this->btnAdd->Click += gcnew System::EventHandler(this, &AddName::btnAdd_Click); 
      // 
      // AddName 
      // 
      this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); 
      this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; 
      this->ClientSize = System::Drawing::Size(284, 262); 
      this->Controls->Add(this->btnAdd); 
      this->Controls->Add(this->UserInstruction); 
      this->Controls->Add(this->NameInput); 
      this->Controls->Add(this->LNCheckBox); 
      this->Controls->Add(this->FNCheckBox); 
      this->Name = L"AddName"; 
      this->Text = L"AddName"; 
      this->ResumeLayout(false); 
      this->PerformLayout(); 

     } 
    #pragma endregion 
    private: System::Void btnAdd_Click(System::Object^ sender, System::EventArgs^ e) 
      { 
       bool warned = false; 
       int duptimes1 = 0; 
       int duptimes2 = 0; 
       String^ Name = NameInput -> Text; 
       string name = marshal_as<std::string>(Name); 
       Generator Pack_Names ("FirstNames.txt", "LastNames.txt"); 
       if (String::IsNullOrEmpty(NameInput->Text)) 
       { 
        MessageBox::Show("Please Enter in a Name to Input!"); 
       } 
       else if (!FNCheckBox-> Checked && !LNCheckBox-> Checked) 
       { 
        MessageBox::Show("Please Check One or Both Boxes."); 
       } 
       //add first or last name to the list, including set-ups for duplicates 
       System::Windows::Forms::DialogResult result; 
       duptimes1 = Pack_Names.CheckDupps(name, 1); 
       duptimes2 = Pack_Names.CheckDupps(name, 2); 
       String^ message = "That name is already in First Names " + duptimes1 + " times and Last Names " + duptimes2 " . Would you like to add it anyways?"; 
       if (FNCheckBox-> Checked) 
       { 
        if (duptimes1 > 0) 
     { 
         result = MessageBox::Show(message, "Multiple Name Error", MessageBoxButtons::YesNo, MessageBoxIcon::Question); 
         warned = true; 
         if (result == System::Windows::Forms::DialogResult::Yes) 
         { 
          Pack_Names.Add(name, 1); //adds name to list 1 
         } 
         else if (result == System::Windows::Forms::DialogResult::No) 
         { 
          //close the window 
         } 
        } 
        else 
        { 
         Pack_Names.Add(name, 1); 
        } 
       } 
       if (LNCheckBox->Checked) 
       { 
        if (duptimes2 > 0 && warned == false) 
        { 
         result = MessageBox::Show(message, "Multiple Name Error", MessageBoxButtons::YesNo, MessageBoxIcon::Question); 
         warned = true; 
         if (result == System::Windows::Forms::DialogResult::Yes) 
         { 
          Pack_Names.Add(name, 2); //adds name to list 2 
         } 
         else if (result == System::Windows::Forms::DialogResult::No) 
         { 
          //close the window 
         } 
        } 
        else 
        { 
         Pack_Names.Add(name, 2); 
        } 
       } 
       //close the window 

      }//End btnAdd 
    }; 
    } 
# Generator.h file # 
    #pragma once 
    #include <string> 
    #include <iostream> 
    #include <vector> 
    #include <iostream> 
    #include <fstream> 
    #include <ctime> 
    #include "StdAfx.h" 
    using namespace std; 

    class Generator 
    { 
    public: 
    Generator(string file_name1, string file_name2); 
    ~Generator(); 
    void Delete(string word, int list); 
    int CheckDupps(string word, int list); 
    int FindName(string word, int list); 
    void Scramble(int list, int times); 
    void Show(int number); 
    void Add(string word, int list); 
    string GetFullName(int number); 
    void Save1(string file_name); 
    void Save2(string file_name); 
    string GetName(int place, int list); 
    int GetSize(int list); 
    void ChangeName(int list, int place, string new_name); 
    void Update(); 
    private: 
    vector <string> First; 
    vector <string> Last; 
    string FileName1; 
    string FileName2; 
    }; 

더 많은 정보 나 어디 어디에 문제가 알아 갈 수 필요한 경우 알려줘을 가지고 초기화 곳 이, 줄 157 내 AddName.h입니다!

+3

_line은 어디에 있습니까? – timrau

+3

틀린 언어 태그. – juanchopanza

+0

라인 157은 어느 것입니까? 코드에 주석으로 표시하십시오. –

답변

4
String^ message = "That name is already in First Names " + duptimes1 + " times and Last Names " + duptimes2 " . Would you like to add it anyways?"; 

마지막에 "+"가 표시되지 않았습니다.

String^ message = "That name is already in First Names " + duptimes1 + " times and Last Names " + duptimes2 + " . Would you like to add it anyways?"; 
+0

+1, 좋은 캐치! – herohuyongtao

+0

그랬어! 정말 고마워! 그것은 나를 데려가는 문제에 대한 분명한 해결책처럼 보입니다. 정말 고맙습니다! – Kerbz713

관련 문제