gpt4 book ai didi

c++ - 使用 C++ 时出现错误 : no matching function for call to ,

转载 作者:行者123 更新时间:2023-11-27 23:19:10 25 4
gpt4 key购买 nike

我是 C++ 的新手,如果有人可以提供对这些错误的指导/见解,请多多指教。这会很有帮助。

以下代码fuzzyex1.cpp:

#include "fuzzyvar.h"


TControlVariable TEMPERATURE(0,1,1200);
TFuzzySet
COLD = TEMPERATURE.Trapezoid(0,0,300,500),
COOL = TEMPERATURE.Trapezoid(100,300,500,700),
TEPID = TEMPERATURE.Trapezoid(300,500,700,900),
WARM = TEMPERATURE.Trapezoid(500,700,900,1100),
HOT = TEMPERATURE.Trapezoid(700,900,1200,1200);


TSolutionVariable POWER(0,1,100);
TFuzzySet
LOW = POWER.Trapezoid(0,0,30,50),
MEDIUM = POWER.Triangle(30,50,70),
HIGH = POWER.Trapezoid(50,70,100,100);

void FuzzyController(float Temperature, float &Power)
{
TEMPERATURE = Temperature;
If (TEMPERATURE is COLD) then (POWER should be HIGH);
If (TEMPERATURE is TEPID) then (POWER should be MEDIUM);
If (TEMPERATURE is WARM) then (POWER should be LOW);
Power = POWER.Defuzzification();
}

出现以下错误:

fuzzyex1.cpp:6: error: no matching function for call to TFuzzySet::TFuzzySet(TFuzzySet)’
fuzzyset.h:14: note: candidates are: TFuzzySet::TFuzzySet(TFuzzySet&)
fuzzyset.h:13: note: TFuzzySet::TFuzzySet(TUniverse*)
fuzzyset.h:12: note: TFuzzySet::TFuzzySet()
fuzzyex1.cpp:7: error: no matching function for call to TFuzzySet::TFuzzySet(TFuzzySet)’
fuzzyset.h:14: note: candidates are: TFuzzySet::TFuzzySet(TFuzzySet&)
fuzzyset.h:13: note: TFuzzySet::TFuzzySet(TUniverse*)
fuzzyset.h:12: note: TFuzzySet::TFuzzySet()

类似的代码行依此类推。

fuzzyset.h如下:

#include "membership.h"
#include "universe.h"

class TFuzzySet
{
protected:
TMembershipDegree *Membership;
TUniverse *Universe;
unsigned Size;
public:
TFuzzySet();
TFuzzySet(TUniverse *AUniverse);
TFuzzySet(TFuzzySet &Set);
void SetUniverse(TUniverse *AUniverse);
TUniverse *GetUniverse();
TMembershipDegree &operator [](unsigned Index);
TMembershipDegree MembershipDegree(float Valor);
void Clear();
TFuzzySet operator or(TFuzzySet &Op2);
TFuzzySet operator and(TFuzzySet &Op2);
TFuzzySet operator not();
TFuzzySet operator and(TMembershipDegree &Op2);
TFuzzySet &operator =(TFuzzySet &Op);
~TFuzzySet() ;
};
class TSolutionFuzzySet : public TFuzzySet
{
public:
TSolutionFuzzySet();
TSolutionFuzzySet(TUniverse *AUniverse);
TSolutionFuzzySet &operator=(TFuzzySet &Op);
float Sum();
float WeightedSum();
float Centroid();
float MaxMean() ;
};

最佳答案

临时变量不能绑定(bind)到非常量引用。

TFuzzySet(TFuzzySet &Set); 更改为 TFuzzySet(const TFuzzySet &Set);

关于c++ - 使用 C++ 时出现错误 : no matching function for call to ,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com