Oct 28, 2020 at 6:29am UTC
Hello!
I keep getting this error no matter what I change and I can solve it
Error C2676 binary '==': 'tipAplicatie' does not define this operator or a conversion to a type acceptable to the predefined operator UnitTests C: 25
My code:
class Autoturism
{
public:
string marca;
string model;
char numarInmatriculare[9];
int putere;
double pret;
Oct 28, 2020 at 7:54am UTC
You need to provide the compilable code that produces the error. Your 'code' is just the start of a class.
Oct 28, 2020 at 9:16am UTC
This is the code I wrote
#include <iostream>
#include <string>
using namespace std;
bool fisierDeschis = true;
enum class tipAplicatie {
aplicatieWeb = 5,
aplicatieMobila = 10,
aplicatieDesktop = 15,
NONE = 0,
};
class Autoturism
{
public:
string marca;
string model;
char numarInmatriculare[9];
int putere;
double pret;
class Autoturism()
{
marca = "Necunoscuta";
model = "Necunoscut";
putere = 0;
pret = 5000;
}
Autoturism(string marca, string model, int putere)
{
this->marca =marca;
this->model = model;
this->putere = putere;
pret = 5000;
}
void discount(int procent)
{
if (procent >= 1 && procent <= 50)
{
pret = pret * (procent / 100.0);
}
}
void seteazaNumarInmatriculare(char numar[])
{
if (strlen(numar) <= 9)
{
strcpy_s(numarInmatriculare, numar);
}
}
char* obtineNumarInmatriculare()
{
return numarInmatriculare;
}
~Autoturism()
{
fisierDeschis = false;
}
};
This is the UniTest code where the error appear a
tipAplicatie rezultat = modificare_enum("aplicatieWeb");
Assert::IsTrue(rezultat == 5, L"Functia nu seteaza corect o aplicatie web");
rezultat = modificare_enum("aplicatieMobila");
Assert::IsTrue(rezultat == 10, L"Functia nu seteaza corect o aplicatie mobila");
rezultat = modificare_enum("aplicatieDesktop");
Assert::IsTrue(rezultat == 15, L"Functia nu seteaza corect o aplicatie desktop");
}
Oct 28, 2020 at 9:39am UTC
I modified and I still get the same error
It might be something on the code? Or in the UnitTest cpp?
Last edited on Oct 28, 2020 at 9:43am UTC
Oct 28, 2020 at 10:48am UTC
againtry where you put //<-- means I should add something?
Oct 28, 2020 at 10:57am UTC
No, where I put a //<-- means where I fixed your program so it compiles and runs.