Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:58:06+00:00 2026-06-01T01:58:06+00:00

I am trying to overload the * operator in order to multiply two objects

  • 0

I am trying to overload the * operator in order to multiply two objects (dot product).

These objects can be Point3D, Vector3D or Normal. They all basically have the same structure (an x, y, and z value), I’ve only split them up for semantics.

The line that is giving me trouble is this:

float t = (point - r.origin)*normal / (r.direction * normal);

Here, point and r.origin are a Point3D, normal is a Normal and r.direction is a Vector3D. In the header files for these classes I have the following overload functions:

In Vector3D.h:

Vector3D operator *(Normal& n);

In Point3D.h:

Point3D operator -(Point3D& p);
Point3D operator *(Normal& n);

The error I get is:

No match for 'operator*' in 'r->Ray::direction * ((const Plane*)this)->Plane::normal'

Assuming I have correctly filled out the functions in the .cpp file, is there anything stupid I’ve done here? Also, ignore the fact that there is no division operator yet…It’s in the pipeline!

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:58:07+00:00Added an answer on June 1, 2026 at 1:58 am

    You may have defined the unary versions instead of the binary versions. (Did you define them inside the class { … } ? )

    Or you may have not defined them as const. Try this:

    Vector3D operator *(const Normal& n) const;
    Point3D operator -(const Point3D& p) const;
    Point3D operator *(const Normal& n) const;
    

    For binary functions over hetrogeneous parameters like this I find it a lot easier to define them all together at global scope in a seperate file/place and friend them from the classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to overload the operator % because you can't use modulus on double
I have to overload the insertion operator in order to view my class objects
I am trying to overload the stream insertion operator so can I print std::vector
Im trying to overload the [] operator in c++ so that I can assign
I am trying to overload == operator to compare objects like below. class A
I am trying to overload operator<< as a member function. It works if simply
Im trying to overload the operator<< const ostream & operator<<(const ostream& out, const animal&
I'm trying to overload the dereference operator, but compiling the following code results in
I am trying to write operator overload for custom class and don't know how
I am trying to overload the assignment operator to do a deep copy of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.