Question:
How To Solve: error C2677: C++?
2009-12-26 02:49:54 UTC
Hello Guys, I'm a Student Learning C++ and I'm trying to make myself a game. I've done various things and now as I'm trying to learn things rather than work around my problems I've always tried to understand what's making them wrong and fix it from that respect.

I'm Now getting a C2677 Error, and while I understand what can cause it, I'm not sure how to solve it in my case, I'm hoping someone could explain Operators to me in a bit more.

The Relevant Code i have is:

float operator*(const float& value, const Vector& v) // This is the Operator I'm trying to make
{
return v.getX() * value + v.getY() * value;
}

Here is the only place the code is used:

Vector PhysicsObject::getAcceleration(void)
{
acceleration.scale(0); //sets Acceleration to 0
for(int count = 0; count < forcesList; count++)
{
acceleration = acceleration + (inverseMass * forces[count]); //this is the line that Generates the Error
}
return acceleration;
}

The Error Given is:

error C2677: binary '*' : no global operator found which takes type 'Vector' (or there is no acceptable conversion)

If any more of my Code is needed please ask I'll add it ASAP. Any help will be greatly appreciated, I've spent a while racking my brains now :(
Four answers:
Germann A
2009-12-26 03:39:32 UTC
I suspect that your inverseMass var is defined as binary, NOT float...
Jim
2009-12-26 03:32:55 UTC
msdn.microsoft.com is your friend if you have a microsoft or windows-compatible compiler.



you apparently didn't define Vector::operator+(...) (which would be next probably) and Vector::operator*



you didn't include the code that shows getX() and getY().



I can't tell from this short snippet what the error is. please supply all and the line number where the error is on. (I suppose it's too big for yahoo...)



somewhere in your code you are trying to multiply something by a Vector. possibly it's a data member in getAccelleration(). either inverseMass or the forces array is a Vector or both. and you need to define a multiply operator for the class Vector. read the articles below.
2009-12-26 03:42:25 UTC
there is no problem in the given code the problem may be in the compilier or in the other part of the program. Download the windows compatible compiler from microsoft's site and then run the program.



Even then if you are not able to solve the problem. Don't worry.

Dude mail me the whole program at bs.parmar007@yahoo.com

Believe me i can solve your problem.
ranking
2016-11-01 11:17:54 UTC
ok uninstall c++ take a stick of butter, rub it on the north factor of the disc, enable it sit down there for around 5-8 hours then rinse it off. next enable it AIR DRY for approximately 20 minutes, then reinstall it. it might now paintings, and scent stable 2 ;)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...