共用Namespace的問題
各位先進們,大家好
小弟是VC++新手,目前在學習開發Window Form程式時,發生
了以下的問題..
我自定了一個namespace First,裡面宣告了兩個變數,依範
例在main中定義First::Run_Path的初值,然後在MainForm
裡,設計時,可以看的到該變數,但是編譯時,確發生了以下
的問題:
錯誤 1 error C2653: 'First' : 不是類別或命名空間名稱 c:\Test\Test\MainForm.h
想請教各位先進,要如何定義該 Namespace 全域都能看的到
的一個命名空間。
// ===============================================
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include "MainForm.h" //包含UI的建構
using namespace std;
using namespace System;
using namespace System::Windows::Forms;
using namespace Manage;
// 自定一個命名空間,名稱為 First
namespace First
{
static string Run_Path = "";
static string CRCL = "\r\n" ;
}
// 主程式
int main(array<System::String ^> ^args)
{
// Console::WriteLine(L"Hello World");
using First::Run_Path ;
Application::EnableVisualStyles() ;
Application::SetCompatibleTextRenderingDefault(false);
Run_Path = "測試字串" ;
Application::Run(gcnew MainForm());
return 0;
}
/// ===========================================================
// 以下為 MainForm 的程式
#pragma once
namespace Manage {
....
...
...
#pragma endregion
private: System::Void MainForm_Load(System::Object^ sender, System::EventArgs^ e)
{
using First::Run_Path ; // <==編譯到此發生問題
this->Text = "管理系統主畫面";
this->ControlBox = false;
// this->label1->Text = BaseCommon::local_path ; // Application::ExecutablePath;
this->label1->Text = Application::ExecutablePath;
}
};
/// <summary>
/// End of MainForm 的摘要
/// </summary>
}
/// <summary>
/// end of namespace Manage
/// <summary>