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

  • Home
  • SEARCH
  • 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 6559937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:23:42+00:00 2026-05-25T13:23:42+00:00

I am having trouble with a C++ object-orientated script. When I create an object,

  • 0

I am having trouble with a C++ object-orientated script. When I create an object, I wish to calculate an AttributeQ based on its attributes MyAValue, MyBValue, and MyCValue.

While using the Visual 2010 debugger, I noticed that TempAttribueQ seems to always be 0 (except before it is initialized of course). Assuming Delta != 0, BVal == Maximum, and DeltaA == DeltaC, then TempAttribueQ should be 1/3 not 0.

At first I thought it was a scope problem, but the variable is defined outside the if-else statements. I have tried initializing TempAttribueQ as some outrageous number, which it keeps up until the if-else statements when it becomes 0 when it shouldn’t.

This is my code…

void SetMyAttribueQ(){

    double TempAVal = MyAValue;
    double TempBVal = MyBValue;
    double TempCVal = MyCValue;

    double Minimum = min(min(TempAVal, TempBVal), TempCVal);
    double Maximum = max(max(TempAVal, TempBVal), TempCVal);
    double Delta = Maximum - Minimum;

    double DeltaA = 0;
    double DeltaB = 0;
    double DeltaC = 0;

    double TempAttribueQ = 0;

    if(Delta == 0) {
        MyAttribueQ = TempAttribueQ; // this->SetMyAttribueQ(TempAttribueQ);
    }
    else {
        DeltaA = /* (a removed equation goes here... */
        DeltaB = /* (a removed equation goes here... */
        DeltaC = /* (a removed equation goes here... */

        if(AVal == Maximum)
            TempAttribueQ = (DeltaC - DeltaB);
        else if(BVal == Maximum)
            TempAttribueQ = (1/3) + (DeltaA - DeltaC);
        else
            TempAttribueQ = (2/3) + (DeltaB - DeltaA);

        MyAttribueQ = TempAttribueQ;
    }
}

What is preventing TempAttribueQ from getting a value of 1/3 or 2/3? Or, what is causing it to be set to be set to 0?

  • 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-25T13:23:43+00:00Added an answer on May 25, 2026 at 1:23 pm

    When you divide one integer by another, you get an integer result. Change either or both the constants to non-integer to fix it – C++ rules will result in the other being converted to floating point before the division takes place. All of the following will work:

    • 1.0 / 3.0
    • 1 / 3.0
    • 1.0 / 3

    An integer will get converted back to a double invisibly, which is why you weren’t seeing any errors in your code.

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

Sidebar

Related Questions

I currently restruct my program to be more object-orientated and I'm having trouble with
I'm having some trouble creating an object in C++. I create a class called
I'm having trouble when I try to create a new object in ExtJS. First
I am having trouble with Subsonic 3.0 generating an object for a table which
I'm having trouble finding information online for creating a object in javascript and pointing
I'm having trouble figuring out how to access a cookie from a compiled object.
I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object.
I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object
I am having some serious trouble creating a WPF TreeView with an Object databinding.
I'm having trouble figuring out how to structure Perl modules in an object oriented

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.