Как вызвать функцию другого класса в заголовочном файле
Я новичок в C++/Cli, так что голый со мной.
Итак, у меня есть класс узла (page3_node.h), page3.h (страница формы) и page3.cpp который состоит из реализации page3_node.h. моя проблема в том, что я пытаюсь получить доступ к методам page3_node.h в page3.h, но я не могу этого сделать. Любая помощь будет очень признательна.
вот три файла.
------------------------------------------страница3.ч----------------------------------------
#pragma once //#include "page1.h" #include<vector> #include"page3_node.h" #include <cliext\vector> #include <string> using namespace System::IO; using namespace std; namespace Team16UserController { 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 System::Collections::Generic; //using namespace System::Array; /// <summary> /// Summary for page3 /// </summary> public ref class page3 : public System::Windows::Forms::Form { public: //node n; page3(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~page3() { if (components) { delete components; } } //add code here to access data of page3_node.h and functions of page3.cpp Team16UserController::node ^ n = gcnew Team16UserController::node; //vector<node^>* vec; cliext::vector<Team16UserController::node^> v; //std::string fName = "tempData.txt"; //Team16UserController::node::readFromFile("tempData.txt",v); private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Button^ button1; 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->label1 = (gcnew System::Windows::Forms::Label()); this->button1 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(165, 40); this->label1->Name = L"label1"; this->label1->Padding = System::Windows::Forms::Padding(5); this->label1->Size = System::Drawing::Size(162, 27); this->label1->TabIndex = 0; this->label1->Text = L"List of Heat Signatures"; this->label1->Click += gcnew System::EventHandler(this, &page3::label1_Click); // // button1 // this->button1->Location = System::Drawing::Point(189, 134); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(138, 55); this->button1->TabIndex = 1; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &page3::button1_Click); // // page3 // this->AutoScaleDimensions = System::Drawing::SizeF(8, 16); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(522, 327); this->Controls->Add(this->button1); this->Controls->Add(this->label1); this->Name = L"page3"; this->Text = L"page3"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { } }; }
--------------------------------------page3_node.h------------------------------------
#pragma once #include <cliext\vector> #include <string> namespace Team16UserController { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Collections::Generic; public ref class node { public: String ^ gps; String^ time; String^ altitude; String^ speed; node(); node(System::String ^, System::String ^, System::String ^, System::String ^); ~node(); cliext::vector<node^>v; void readFromFile(std::string filename, cliext::vector<node^>v); }; }
----------------------------------------page3.cpp-------------------------------------
nclude "page3.h" #include "page3_node.h" #include <string> #include <iostream> #include <fstream> #include <strstream> #include<sstream> #define ARRAY_SIZE 4; using namespace System::IO; using namespace std; Team16UserController::node::node() { gps = nullptr; speed = nullptr; time = nullptr; altitude = nullptr; } Team16UserController::node::node(System::String ^ dtime, System::String ^ dGps, System::String ^ dSpeed, System::String ^ dAltitude) { gps = dGps; time = dtime; speed = dSpeed;; altitude = dAltitude; } Team16UserController::node::~node() { throw gcnew System::NotImplementedException(); } void Team16UserController::node::readFromFile(std::string filename, cliext::vector<node^> v) { node^ n = gcnew node(); std::string data; cliext::vector<System::String^> eachLineData; ifstream inFile(filename); while (getline(inFile, data)) { std::istringstream ss(data); string token; while (getline(ss, token, ',')) { String^ eachData = gcnew String(token.c_str()); eachLineData.push_back(eachData); } n->gps = eachLineData[0]; n->time = eachLineData[1]; n->speed = eachLineData[2]; n->altitude = eachLineData[3]; v.push_back(n); eachLineData.clear(); } }
Что я уже пробовал:
все, что я могу придумать