473,379 Members | 974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 1486

<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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.