VTMEC++'s Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
20 (0.03 per day)
Joined:
03-June 12
Profile Views:
163
Last Active:
User is offline Jun 21 2012 05:18 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   VTMEC++ has not set their status

Posts I've Made

  1. In Topic: How do I receive a value from the driver file into a header file?

    Posted 20 Jun 2012

    Never mind, I figured it out. I had to use *this in my operator^ function to call the original object.
  2. In Topic: How do I receive a value from the driver file into a header file?

    Posted 20 Jun 2012

    My compiler gives no warnings when I run my program. I am using Visual Studio 2010. I change the equal sign to a less than but it is still doing the same thing. No matter what power I input, it just squares it and outputs it.
  3. In Topic: Error C2661

    Posted 12 Jun 2012

    Thank you for pointing out the problem in the constructor. Once again I am making silly mistakes. So, that solved a bunch of my problems. Now, I fixed the warning of converting from double to int on lines 28-30 by changing my code on lines 19-20 in the header file to this:

    int NumBox(double length_box) const {return ((int)(getLength()/length_box))*((int)(getWidth()/length_box))*((int)(getHeight()/length_box));}
    


    Now I only have three warnings of conversion coming up from lines 39-41 in the source file. How would I round the calculation on lines 21-22 in my header file up to the nearest whole number?
  4. In Topic: Error C2661

    Posted 12 Jun 2012

    Here is my new header file:

    #include<iostream>
    #include<cmath>
    using namespace std;
    
    class TruckLoad
    {
    private:
    	double length, width, height, weight;
    	
    public:
    	TruckLoad(double L = -1, double W = -1, double H = -1, double WT = -1)
    	{
    		double length = L;
    		double width = W;
    		double height = H;
    		double weight = WT;
    	}
    	double getLength() const {return length;}
    	double getWidth() const {return width;}
    	double getHeight() const {return height;}
    	double getWeight() const {return weight;}
    	double NumBox(double length_box) const { return (length/length_box)*(width/length_box)*(height/length_box);}
    	double NumTruck(int number_boxes, double length_box, double weight_box) const { return ((NumBox(length_box)*weight_box)/weight);}
    };
    
    


    It is still the same source file as above because it cannot be changed. Here are the warnings I am getting:


    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(34): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(35): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(36): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(44): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(45): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
    1>c:\users\tyler\documents\visual studio 2010\projects\hw8\hw8\hw8.cpp(46): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
  5. In Topic: Error C2661

    Posted 12 Jun 2012

    Wow, how did I miss that? Alright so now that I have that done. How do I do a conversion from double to int? I am getting a bunch of warnings for that.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

VTMEC++ hasn't added any friends yet.

Comments

VTMEC++ has no profile comments yet. Why not say hello?