0

どんな助けでも大歓迎です。私の問題を確認するために時間を割いていただき、ありがとうございます。

現在、エラーが発生しています

 1>c:\users\fordn_000\documents\tcc_odu\it310\programs\it310_homework_program_2_nford\it310_homework_program_2_nford\Form1.h(625): error C2653: 'Marshal' : is not a class or namespace name
 1>c:\users\fordn_000\documents\tcc_odu\it 310\programs\it310_homework_program_2_nford\it310_homework_program_2_nford\Form1.h(625): error C3861: 'StringToHGlobalAnsi': identifier not found

これは私の GUI フォーム コードです。コマンド marshal を使用したいのですが、エラーが発生している場所に表示されます

    private: System::Void DisplayButton_Click(System::Object^  sender, System::EventArgs^  e) 
     {
         int InitProductID = 0;
         char* InitDescription;
         int InitManufID = 0;
         double InitWholeSale = 0.0;
         double InitMarkup = 0.0;
         int InitQuanity = 0;

         String^ TypeString;

         //EXTRACT FROM INPUT TEXT BOX'S
         InitProductID = Convert::ToInt32(ProductIDNumberBoxNew->Text);
         InitDescription = (char*)(void*)Marshal::StringToHGlobalAnsi(DescriptionBox->Text);
         InitManufID = Convert::ToInt32(ManufacturerBox->Text);
         InitWholeSale = Convert::ToDouble(WholesalePriceBox->Text);
         InitMarkup = Convert::ToDouble(MarkupBox->Text);
         InitQuanity = Convert::ToInt32(QuantityBox->Text);

         //CREATE INSTANCE OF CLASS
         Inventory InventoryItem(InitProductID, InitDescription, InitManufID, InitWholeSale, InitMarkup, InitQuanity);

         //DISPLAY TO OUTPUT TEXT BOXS
         ProductIDNumberOutBox->Text = Convert::ToString(InventoryItem.GetProductID());
         TypeString=gcnew String(InventoryItem.GetDescription());
         ManufacturerOutBox->Text = Convert::ToString(InventoryItem.GetManufID());
         //RETAIL PRICE OUTBOX
         QuantityOutBox->Text= Convert::ToString(InventoryItem.GetQuanity());


     }

これは、以下の stdafx ヘッダー ファイルです。

 #pragma once

 // TODO: reference additional headers your program requires here
 #include "Inventory.h"

これは私のstdafx cppファイルです

#include "stdafx.h"
#include "Form1.h"

最後に、これは私のインベントリ ヘッダー ファイルです

//SPECIFICATION FILE (INVENTORY.H)
#ifndef INVENTORY_H
#define INVENTORY_H

#include <iostream>
#include <iomanip>

  using namespace std;

 class Inventory 
 {
 private:
int ProductID;
mutable char Description[25];
int ManufID;
double WholeSale;
double Markup;
int Quanity; 

public:
//CONSTRUCTORS
Inventory( );
Inventory(int, char[], int, double, double, int);

//GET FUNCTIONS
int GetProductID( )const;
char* GetDescription( )const;
int GetManufID( )const;
double GetWholeSale( )const;
double GetMarkup( )const;
int GetQuanity( )const;

//DISPLAY FUNCTION
void Display( )const;

//RETURN FUNCTION
double RetailPrice( )const;

};
#endif
4

1 に答える 1

2

これを参照する必要があると思います:

using namespace System::Runtime::InteropServices;
于 2013-10-31T04:39:42.543 に答える