Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am new to C++, Please if anyone could provide guidance/insight into these errors. It would be of great help.

The following code 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();
}

Gives the following Error:

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()

and so on for the similar lines of code.

The fuzzyset.h is as follows:

#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() ;
 };
share|improve this question
@harper This is the real code, it’s just formatted unconventionally. – Konrad Rudolph Jan 28 at 11:34

1 Answer

Temporaries can't be bound to non-const references.

Change TFuzzySet(TFuzzySet &Set); to TFuzzySet(const TFuzzySet &Set);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.