Thread: Math problems, I think...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    118

    Question Math problems, I think...

    Hey,

    Stupidity has brought me here again.

    Can anyone tell me why I just get a bunch of 'non-lvalue' s on this?

    Code:
    #include <iostream>
    
    using namespace std;
    
    class CalculateCube
    {
    public:
            CalculateCube();
            ~CalculateCube();
            void CalculatePointsFromValues(int centerX, int centerY, int size);
            int CenterPointGivenX;
            int CenterPointGivenY;
            int SizeGiven;
            int PointOneX;
            int PointOneY;
            int PointTwoX;
            int PointTwoY;
            int PointThreeX;
            int PointThreeY;
            int PointFourX;
            int PointFourY;
            int PointFiveX;
            int PointFiveY;
            int PointSixX;
            int PointSixY;
            int PointSevenX;
            int PointSevenY;
            int PointEightX;
            int PointEightY;
        protected:
            int HalfSizeGiven;
    };
    
    CalculateCube::CalculateCube()
    {
    
    }
    
    CalculateCube::~CalculateCube()
    {
    
    }
    
    void CalculateCube::CalculatePointsFromValues(int centerX, int centerY, int size)
    {
        CenterPointGivenX = centerX;
        CenterPointGivenY = centerY;
        SizeGiven = size;
    
        SizeGiven / 2 = HalfSizeGiven;
    
        CenterPointGivenX + HalfSizeGiven = PointOneX;
        CenterPointGivenX + HalfSizeGiven = PointTwoX;
        CenterPointGivenX + HalfSizeGiven = PointThreeX;
        CenterPointGivenX + HalfSizeGiven = PointFourX;
    
        CenterPointGivenX - HalfSizeGiven = PointFiveX;
        CenterPointGivenX - HalfSizeGiven = PointSixX;
        CenterPointGivenX - HalfSizeGiven = PointSevenX;
        CenterPointGivenX - HalfSizeGiven = PointEightX;
    
        CenterPointGivenY + HalfSizeGiven = PointOneY;
        CenterPointGivenY + HalfSizeGiven = PointTwoY;
        CenterPointGivenY + HalfSizeGiven = PointFiveY;
        CenterPointGivenY + HalfSizeGiven = PointSixY;
    
        CenterPointGivenY - HalfSizeGiven = PointThreeY;
        CenterPointGivenY - HalfSizeGiven = PointFourY;
        CenterPointGivenY - HalfSizeGiven = PointSevenY;
        CenterPointGivenY - HalfSizeGiven = PointEightY;
    }
    Thanks!
    FlyingIsFun1217

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    You've got all of your assignments backwards...

    Code:
    int a = 5, b = 6, c = 7;
    ...
    a = b + c; /* Right! */
    b + c = a; /* WRONG WRONG WRONG */
    ...

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    The last 17 equations of your code don't have valid lvalues (i.e., the expression on the left that you're trying to assign to, can't be).

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    118
    Ok, didn't realize it had to be in that order
    Thanks for helping me

    FlyingIsFun1217

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. American math students ...
    By whiteflags in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 05-26-2008, 12:47 PM
  3. Random math problems
    By got1sleeve in forum C++ Programming
    Replies: 3
    Last Post: 01-23-2008, 11:20 PM
  4. making a math quiz program
    By mackieinva in forum C Programming
    Replies: 10
    Last Post: 09-17-2007, 03:38 PM
  5. Library for matrix math/ linear algebra?
    By The V. in forum C++ Programming
    Replies: 0
    Last Post: 09-25-2001, 10:36 PM