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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:06:51+00:00 2026-05-16T07:06:51+00:00

I found in some legacy code I’m dealing with this function (in C++) Vec3d

  • 0

I found in some legacy code I’m dealing with this function (in C++)

Vec3d Minimum()
{
    if(this->valid)
    {
        return minBB;
    }
    else
    {
        return NULL;
    }
}

where Vec3d is a object that is basically a struct with x,y,z and some operators overloaded (code below).

AFAIK, you can’t return a 0 for a user defined object… or is there some automatic cast to zero that I didn’t know about? This is just out of curiosity :p

Thanks

class Vec3d
{
public:
    double x,y,z;

    /// \brief Default constructor initializes x and y to 0
    Vec3d();

    /** \brief Constructor initializies vector to input parameters x and y and z
     *
     *  \param x Double value that initializes x value of vector
     *  \param y Double value that initializes y value of vector
     *  \param z Double value that initializes z value of vector
     */
    Vec3d(double x, double y, double z);

    /** \brief Copy constructor
     *
     *  \param v Pointer to another vec3i with which to initialize current vec3i
     */
    Vec3d(Vec3d* v);

    /**\brief Sets a vector (already instantiated) to the input parameters (x,y,z)
     *
     *  \param x Double value that initializes x value of vector
     *  \param y Double value that initializes y value of vector
     *  \param z Double value that initializes z value of vector
     *
     *  This method is just so you can change the value of an already instantiated vector
     */
    void set(double xi, double yi, double zi);

    const Vec3d operator -(const Vec3d &other) const;
    const Vec3d operator +(const Vec3d &other) const;
    const Vec3d operator *(const double num) const;
    const double operator *(const Vec3d &other) const;
    const Vec3d operator /(const double num) const;
    double magnitude();
};
  • 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-16T07:06:52+00:00Added an answer on May 16, 2026 at 7:06 am

    0 can be used in the context of pointers to be the null pointer constant. That is, it’s going into here:

    Vec3d(Vec3d* v); 
    

    Note the comment is incorrect, as that is not a copy-constructor.

    The code is a bit shoddy. There doesn’t need to be a set function, and typically non-mutating operators should be free-functions. And not least of all, having a constructor like it has is a waste and confusing. If you have a pointer to a vector, you should do:

    Vec3d v = *other;
    

    Not provide an implicit conversion from a pointer.

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Git add + git commit -m will just commit those… May 16, 2026 at 2:00 pm
  • Editorial Team
    Editorial Team added an answer You can use the Flex Framework to make commercial products… May 16, 2026 at 2:00 pm
  • Editorial Team
    Editorial Team added an answer Oracle sequences work that way. They only guarantee uniqueness but… May 16, 2026 at 2:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Doing some refactoring in some legacy code I've found in a project. This is
I'm reviewing some legacy code and I've found a bug that causes the response
I've found myself running back through some old 3.5 framework legacy code, and found
I'm dealing with some legacy code that stores its data in a proprietary string
I have some legacy code that provides a list of the available COM ports
I'm trying to refactor some legacy code to use Spring to handle the jms
I'm working with some legacy code that has an import like so: #import C:\Program
Today, I have seen some legacy code. In the destructor there is a statement
I am trying to figure out what some legacy code is doing. What exactly
I found some code at http://labnol.blogspot.com/2006/12/allow-site-visitors-to-change-font.html to allow folks to change font size and

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.