P
PhreakRox
Hello, I am new to c++ Win32 coding, actually this is the first time
Ive really tried to make a program with it. I was trying to create a
"love calculator" program, this exerpt is tha part which compares the
length of the 2 different names. It does not compile, and instead
gives me 3 errors and 4 warnings, could someone please tell me what I
am doing wrong? Help would be greatly appreciated.
Errors/Warnings:
Warning 1 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 2 warning C4018: '<' : signed/unsigned mismatch
Warning 3 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 4 warning C4018: '<' : signed/unsigned mismatch116
Error 5 error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::length':
function call missing argument list; use
'&std::basic_string<_Elem,_Traits,_Ax>::length' to create a pointer to
member
Error 6 error C2446: '==' : no conversion from '__w64 unsigned int' to
'__w64 unsigned int (__thiscall std::basic_string<_Elem,_Traits,_Ax>::*
)(void) const'
Error 7 error C2040: '==' : '__w64 unsigned int (__thiscall
std::basic_string<_Elem,_Traits,_Ax>::* )(void) const' differs in
levels of indirection from '__w64 unsigned int'
Code:
int Calculate(string p1FirstName, string p1LastName, string
p2FirstName, string p2Lastname, string p1Sex, string p2Sex)
{
int Percentage = 0;
if (p1FirstName.length() > p2FirstName.length())
{
int x = p2FirstName.length();
int i = 10;
while ( x < p1FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length() < p2FirstName.length())
{
int x = p1FirstName.length();
int i = 10;
while ( x < p2FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length == p2FirstName.length())
{
Percentage += 10;
}
return Percentage;
}
Ive really tried to make a program with it. I was trying to create a
"love calculator" program, this exerpt is tha part which compares the
length of the 2 different names. It does not compile, and instead
gives me 3 errors and 4 warnings, could someone please tell me what I
am doing wrong? Help would be greatly appreciated.
Errors/Warnings:
Warning 1 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 2 warning C4018: '<' : signed/unsigned mismatch
Warning 3 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 4 warning C4018: '<' : signed/unsigned mismatch116
Error 5 error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::length':
function call missing argument list; use
'&std::basic_string<_Elem,_Traits,_Ax>::length' to create a pointer to
member
Error 6 error C2446: '==' : no conversion from '__w64 unsigned int' to
'__w64 unsigned int (__thiscall std::basic_string<_Elem,_Traits,_Ax>::*
)(void) const'
Error 7 error C2040: '==' : '__w64 unsigned int (__thiscall
std::basic_string<_Elem,_Traits,_Ax>::* )(void) const' differs in
levels of indirection from '__w64 unsigned int'
Code:
int Calculate(string p1FirstName, string p1LastName, string
p2FirstName, string p2Lastname, string p1Sex, string p2Sex)
{
int Percentage = 0;
if (p1FirstName.length() > p2FirstName.length())
{
int x = p2FirstName.length();
int i = 10;
while ( x < p1FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length() < p2FirstName.length())
{
int x = p1FirstName.length();
int i = 10;
while ( x < p2FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length == p2FirstName.length())
{
Percentage += 10;
}
return Percentage;
}