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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:03:33+00:00 2026-05-26T11:03:33+00:00

I have a class CS which is to represent the co-ordinate system in 3D

  • 0

I have a class CS which is to represent the co-ordinate system in 3D i.e.(x, y, z)

class CS
{
  private:
        double x;
        double y;
        double z;
}

CS::CS()
{
   x = NULL;//this causes x = 0//i want the address of x to be 0x000000 & not x = 0
   y = NULL;
   z = NULL:
}

I want that the user can create a CS (0, 0, 0).
In the constructor i want to initialise the address of x, y & z to NULL.
this is to differentiate between the user defined (0, 0, 0) & the default value.
I am creating the objects of CS dynamically, so there is no point in using the following code:

class CS
{
  private:
        double *x;
        double *y;
        double *z;
}

CS:CS()
{
    x = new double;
    x = NULL;
    //same for y & z
}

Primarily, i want to manually assign 0x000000 address to any variable(int or double or char) without using pointers.
any suggestions?

  • 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-26T11:03:34+00:00Added an answer on May 26, 2026 at 11:03 am

    You can’t change the positions of x,y,and z to be NULL, since there positions will always be offsets from the CS object. They will always exist. It’s not that CS has an x like you have a car, it’s like CS has an x like you have a head. You can’t not have a head. If they were integers, you would have to make them pointers (like you said you didn’t want to do), because that would be the only way to tell uninitialized from initialized. However, doubles have a magic value that is rarely used:

    CS:CS()
    : x(std::numeric_limits<double>::quiet_NaN())
    : y(std::numeric_limits<double>::quiet_NaN())
    : z(std::numeric_limits<double>::quiet_NaN())
    { }
    

    Users probably won’t be setting x, y, and z to (NOT A NUMBER) intentially.

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

Sidebar

Related Questions

I have a class which looks something like this: public class Test { private
I have a class which is marked with a custom attribute, like this: public
I have a class let's say MyJFrame which represent the GUI of my application.
I have a class Parameter, the purpose of which is to represent the possible
I have a class which represents a shape. The Shape class has a property
Say I have a class which represents a person, a variable within that class
I have a Location class which represents a location somewhere in a stream. (The
If I have a table in MySQL which represents a base class, and I
I have, for my game, a Packet class, which represents network packet and consists
I have a class which I'm serialising to send over a unix socket 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.