472,363 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,363 software developers and data experts.

Operator overloading wierdness

Hello, i'm trying to make a simple friend function for multipling a
vector and a matrix together. I'm getting a very wierd error and I
don't know why. Here is the code snipits:

Friend function prototype:

jVector4 operator*(const jVector4& vec, const jMatrix44& mat);

Code sample...........

jVector4 test_vector;
jMatrix44 test_matrix;

test_vector * test_matrix;

............end code sample

That last line is giving me this error in VS.NET:

error C2678: binary '*' : no operator found which takes a left-hand
operand of type 'jVector4' (or there is no acceptable conversion)

Any ideas what i'm doing wrong?

Thanks,
-Josh

Jul 23 '05 #1
4 1447

<tw******@gmail.com> skrev i en meddelelse
news:11**********************@g43g2000cwa.googlegr oups.com...
Hello, i'm trying to make a simple friend function for multipling a
vector and a matrix together. I'm getting a very wierd error and I
don't know why. Here is the code snipits:

Friend function prototype:

jVector4 operator*(const jVector4& vec, const jMatrix44& mat);

Code sample...........

jVector4 test_vector;
jMatrix44 test_matrix;

test_vector * test_matrix;

...........end code sample

That last line is giving me this error in VS.NET:

error C2678: binary '*' : no operator found which takes a left-hand
operand of type 'jVector4' (or there is no acceptable conversion)

Any ideas what i'm doing wrong?
It is not enough to declare it as a friend. You should also declare it as a
stand-alone function.

/Peter
Thanks,
-Josh

Jul 23 '05 #2
tw******@gmail.com wrote:
Hello, i'm trying to make a simple friend function for multipling a
vector and a matrix together. I'm getting a very wierd error and I
don't know why. Here is the code snipits:

Friend function prototype:

jVector4 operator*(const jVector4& vec, const jMatrix44& mat);

Code sample...........

jVector4 test_vector;
jMatrix44 test_matrix;

test_vector * test_matrix;

...........end code sample
This sample is not large enough to diagnose the problem.
That last line is giving me this error in VS.NET:

error C2678: binary '*' : no operator found which takes a left-hand
operand of type 'jVector4' (or there is no acceptable conversion)

Any ideas what i'm doing wrong?


You're not following the recommendations of the FAQ 5.8.

V
Jul 23 '05 #3


tw******@gmail.com wrote:
Hello, i'm trying to make a simple friend function for multipling a
vector and a matrix together. I'm getting a very wierd error and I
don't know why. Here is the code snipits:

Friend function prototype:

jVector4 operator*(const jVector4& vec, const jMatrix44& mat);

Code sample...........

jVector4 test_vector;
jMatrix44 test_matrix;

test_vector * test_matrix; Try
jVector4 result = test_vector * test_matrix;

Does it work?

...........end code sample

That last line is giving me this error in VS.NET:

error C2678: binary '*' : no operator found which takes a left-hand
operand of type 'jVector4' (or there is no acceptable conversion)

Any ideas what i'm doing wrong?

Thanks,
-Josh


Jul 23 '05 #4
tw******@gmail.com wrote:
Friend function prototype:

jVector4 operator*(const jVector4& vec, const jMatrix44& mat);

Code sample...........

jVector4 test_vector;
jMatrix44 test_matrix;

test_vector * test_matrix;

...........end code sample

That last line is giving me this error in VS.NET:

error C2678: binary '*' : no operator found which takes a left-hand
operand of type 'jVector4' (or there is no acceptable conversion)

Any ideas what i'm doing wrong?

Hello Josh,

`no operator found' may mean
- there is none, or
- it is hidden

As your friend statement is an implicit declaration, I guess the latter:

Did you declare any of
- jVector4::operator*()
- jMatrix44::operator*()
(These will hide your friend declaration, no matter, what arguments they
take).
HTH,
Ralph
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
34
by: Pmb | last post by:
I've been working on creating a Complex class for my own learning purpose (learn through doing etc.). I'm once again puzzled about something. I can't figure out how to overload the assignment...
16
by: gorda | last post by:
Hello, I am playing around with operator overloading and inheritence, specifically overloading the + operator in the base class and its derived class. The structure is simple: the base class...
2
by: pmatos | last post by:
Hi all, I'm overloading operator<< for a lot of classes. The question is about style. I define in each class header the prototype of the overloading as a friend. Now, where should I define the...
67
by: carlos | last post by:
Curious: Why wasnt a primitive exponentiation operator not added to C99? And, are there requests to do so in the next std revision? Justification for doing so: C and C++ are increasingly used...
6
by: jay | last post by:
In the c++ primer ,i get a program. A class's name is TT,and it define the operator overload! TT first; //constructor TT second(30);//constructor TT thrid(40://constructor...
3
by: karthik | last post by:
The * operator behaves in 2 different ways. It is used as the value at address operator as well as the multiplication operator. Does this mean * is overloaded in c?
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
8
by: Wayne Shu | last post by:
Hi everyone, I am reading B.S. 's TC++PL (special edition). When I read chapter 11 Operator Overloading, I have two questions. 1. In subsection 11.2.2 paragraph 1, B.S. wrote "In particular,...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.