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 3279934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:38:53+00:00 2026-05-17T19:38:53+00:00

I am trying to override the = operator so that I can change my

  • 0

I am trying to override the = operator so that I can change my Point class into a Vector3 class.

Point tp = p2 - p1;
Vec3 v;
v = tp;

The problem I am facing is that, “v” will have its x,y,z members equal to zero all the time.

Vec3.h:

Vec3 operator =(Point a) const;

Vec3.cpp:

Vec3 Vec3::operator =(Point a) const
    {
        return Vec3(a.x,a.y,a.z);
    }

Thanks for all the help once again 🙂

  • 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-05-17T19:38:54+00:00Added an answer on May 17, 2026 at 7:38 pm

    It’s been a while, but I think you want

    Vec3& Vec3::operator=(const Point &a) 
    {
        x = a.x; y = a.y; z = a.z;
    
        return *this;  // Return a reference to myself.
    }
    

    Assignment modifies ‘this’, so it can’t be const. It doesn’t return a new Vec3, it modifies an existing one. You will also probably want a copy constructor from Point, that does the same.

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

Sidebar

Related Questions

im trying to override the add() but it will not compile public class AVLTree<E
I ran into a problem today trying to override an implementation of an interface
I'm trying to do some refactoring of code, and have run into a problem.
I am trying to override FOSUserBundle for the only reason that I can put
I am trying to override equals method in Java. I have a class People
I'm trying to override the setter of an NSManagedObject so that I can pass
I'm trying to override SonataUserBundle's ProfileFormType. I have added some extra fields to that
I'm trying to override the equality (==) operator in C# to handle comparing any
I'm trying to override a JSP in Liferay 6.1, namely html/portlet/enterprise_admin/settings/authentication.jsp. I have created
I'm trying to override a method inside a jquery widget. The method can be

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.