我正在處理以下問題。是正式的,我使用VS2010 Ultimate和我嘗試寫一個Windows窗體應用程序,但我得到指定的錯誤:C++/CLI - 錯誤C2664再次
1>f:\baza danych\baza\baza\Form5.h(475): error C2664: 'Bazadanych::Dodaj1' : cannot convert parameter 1 from 'Car' to 'Car'
1> Cannot copy construct class 'Car' due to ambiguous copy constructors or no available copy constructor
,這裏是Car.h在那裏我有這個類的聲明
public ref class Car
{
public:
String^ category;
String^ model;
String^ rocznik;
String^ cena;
Car(){};
Car(String^ ,String^ ,String^);
void edytuj(String^ ,String^ ,String^);
String^ getmodel(){return this->model;};
String^ getrocznik(){return this->rocznik;};
String^ getcena(){return this->cena;};
virtual String^ getcat()
{
this->category="To rent";
return this->category;
};`
}
定義:
Car::Car(String^ model1,String^ rocznik1,String^ cena1)
{
this->model=model1;
this->rocznik=rocznik1;
this->cena=cena1;
};
void Car::edytuj(String^ model1,String^ rocznik1,String^ cena1)
{
this->model=model1;
this->rocznik=rocznik1;
this->cena=cena1;
};
類的宣言其中錯誤提到的方法是:
public ref class Bazadanych
{
public:
cliext::list<Car^> Bazatorent;
cliext::list<Rented^> Bazarented;
cliext::list<Unavaible^> Bazaunavaible;
cliext::list<Car^>::iterator it1;
cliext::list<Rented^>::iterator it2;
cliext::list<Unavaible^>::iterator it3;
Bazadanych()
{
it1=Bazatorent.begin();
it2=Bazarented.begin();
it3=Bazaunavaible.begin();
};
bool Empty();
void Dodaj1(Car);
void Dodaj2(Rented);
void Dodaj3(Unavaible);
void Usun1(Car);
void Usun2(Rented);
void Usun3(Unavaible);
void Czysc();
};
和定義:
void Bazadanych::Dodaj1(Car Element)
{
this->Bazatorent.push_back(Element);
};
我在separatly的.h和.cpp文件定義和聲明。對於其他方法「Dodaj」和「Usun」,我有完全相同的問題。如果它可以幫助Car類成爲Rented和Unavaible類的基類。我在C++/CLI中很新,所以如果有人能幫助我,我將非常感激。
加入後^我得到改變錯誤」 C2664'˚F :\ baza danych \ baza \ baza \ Form5.h(485):error C2664:'Bazadanych :: Dodaj3':無法將參數1從'Unavaible'轉換爲'Unavaible ^' 1>沒有用戶定義的轉換運算符可用,或者 1>沒有可以執行th的用戶定義轉換操作符是轉換,或者操作員不能被稱爲' – user2116987 2013-02-27 21:00:00
感謝它正在工作;) – user2116987 2013-02-27 21:13:38