以下时c++中调用c#中的batchannealing类的代码:
Class1 ^a=gcnew Class1();
double kk=a->batchannealing(jihua,jihua1,jihua2,maxjobdonetime);
jihua是结构体数组,如果想上面那样写的话会报错:
错误 1 error C2664: “batchannealing::Class1::batchannealing”: 不能将参数 1 从“jih *”转换为“cli::array<Type,dimension> ^”
我感觉是不是应该将jihua从jih指针型转换成托管c++的cli::array<Type,dimension> ^这种形式,单卧不知道可不可以。希望各位高手指点,谢谢
7 个解决方案
#1
麻煩寫詳細點,把batchannealing及Class1的類定義及jihua結構體寫清楚,越細越能瞭解你的問題。
#2
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
#3
jihua结构体:
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
以下是c#中的代码:
namespace batchannealing
{
public class Class1
{
myLink ml = new myLink();
anneal_event ae = new anneal_event();
//structData st = new structData();
rezh[] re = new rezh[23];
lengzh[] lz = new lengzh[23];
hangche[] hc = new hangche[2];
timecalculate[] tc = new timecalculate[1000];
DateTime current = new DateTime();
DateTime begin = new DateTime();
int x = 0;
string makespan = "";
double totalwaittime = 0;
double totalfreetime = 0;
double jiartime = 0; //加热时间
double lengqtime = 0; //冷却时间
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
batchannealing方法太长,省略了。
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
以下是c#中的代码:
namespace batchannealing
{
public class Class1
{
myLink ml = new myLink();
anneal_event ae = new anneal_event();
//structData st = new structData();
rezh[] re = new rezh[23];
lengzh[] lz = new lengzh[23];
hangche[] hc = new hangche[2];
timecalculate[] tc = new timecalculate[1000];
DateTime current = new DateTime();
DateTime begin = new DateTime();
int x = 0;
string makespan = "";
double totalwaittime = 0;
double totalfreetime = 0;
double jiartime = 0; //加热时间
double lengqtime = 0; //冷却时间
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
batchannealing方法太长,省略了。
#4
稍微看了一下,請問樓主為甚不用CLI的方式寫VC的結構體?這樣就不用做CString <--> String 轉換。
#5
抱歉說錯,應該是為甚不用CLI的方式寫C++的結構體?因為CLI都是相容了,就不用考慮太多東西。
#6
另,能否麻煩你簡單的用上面的資料寫一下程式(像宣告,代入等),但不要像你問問題的那麼簡單,那會捉不到重點。
#7
array<type>^
#1
麻煩寫詳細點,把batchannealing及Class1的類定義及jihua結構體寫清楚,越細越能瞭解你的問題。
#2
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
#3
jihua结构体:
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
以下是c#中的代码:
namespace batchannealing
{
public class Class1
{
myLink ml = new myLink();
anneal_event ae = new anneal_event();
//structData st = new structData();
rezh[] re = new rezh[23];
lengzh[] lz = new lengzh[23];
hangche[] hc = new hangche[2];
timecalculate[] tc = new timecalculate[1000];
DateTime current = new DateTime();
DateTime begin = new DateTime();
int x = 0;
string makespan = "";
double totalwaittime = 0;
double totalfreetime = 0;
double jiartime = 0; //加热时间
double lengqtime = 0; //冷却时间
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
batchannealing方法太长,省略了。
struct jih
{
CString lutai;
CString jihh;
CString currentoperate;
CString time;
CString hangch;
CString rezhao;
CString lengzhao;
CString waittime; //记录等待时间
CString waitb; //记录等待开始时间
CString freetime; //记录抛空时间
CString time1; //保存初始剩余时间
CString lengquetime;
CString jiaretime;
};
以下是c#中的代码:
namespace batchannealing
{
public class Class1
{
myLink ml = new myLink();
anneal_event ae = new anneal_event();
//structData st = new structData();
rezh[] re = new rezh[23];
lengzh[] lz = new lengzh[23];
hangche[] hc = new hangche[2];
timecalculate[] tc = new timecalculate[1000];
DateTime current = new DateTime();
DateTime begin = new DateTime();
int x = 0;
string makespan = "";
double totalwaittime = 0;
double totalfreetime = 0;
double jiartime = 0; //加热时间
double lengqtime = 0; //冷却时间
public double batchannealing(jih[] jihua, dengpaichan[] jihua1, ableresorce[] jihua2,ChargeMode mode)
{
//扫描条件事件表
int count = 0;
string[] newjihua = new string[count];
count = jihua.Length;
int countall=count;
bool isxiere = false;
//int end = 0;
........
}
batchannealing方法太长,省略了。
#4
稍微看了一下,請問樓主為甚不用CLI的方式寫VC的結構體?這樣就不用做CString <--> String 轉換。
#5
抱歉說錯,應該是為甚不用CLI的方式寫C++的結構體?因為CLI都是相容了,就不用考慮太多東西。
#6
另,能否麻煩你簡單的用上面的資料寫一下程式(像宣告,代入等),但不要像你問問題的那麼簡單,那會捉不到重點。
#7
array<type>^