Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2008 by Ivor Horton; ISBN: 9780470225905
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 3rd, 2013, 12:24 PM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ivor Horton visual C++ 2008 Ex8_08

i keep on receiving this message as error each time I build the project
//PLEASE HELP ME
//I WILL BE VERY GREATFUL
//PATIENTLY WAITING FOR HELP FROM YOU GUYS

THIS IS THE ERROR MESSAGE
************************************************** ****
Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup C:\Users\Eben\documents\visual studio 2010\Projects\Ex8_08\Ex8_08\MSVCRTD.lib(crtexew.ob j)
Error 2 error LNK1120: 1 unresolved externals C:\Users\Eben\documents\visual studio 2010\Projects\Ex8_08\Debug\Ex8_08.exe 1
************************************************** ****

THIS IS THE OUTPUT MESSAGE
************************************************** **
1>------ Build started: Project: Ex8_08, Configuration: Debug Win32 ------
1>Build started 03/04/2013 14:32:10.
1>InitializeBuildStatus:
1> Touching "Debug\Ex8_08.unsuccessfulbuild".
1>ClCompile:
1> Box.cpp
1> Generating Code...
1> Skipping... (no relevant changes detected)
1> Ex8_08.cpp
1> BoxOperators.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Eben\documents\visual studio 2010\Projects\Ex8_08\Debug\Ex8_08.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.86
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
************************************************** *******


these are the codes

//*************************************************
// Ex8_08.cpp
// A sample packaging problem
#include <iostream>
#include "Box.h"
#include "BoxOperators.h"
using std::cout;
using std::endl;
int main(void)
{
CBox candy(1.5, 1.0, 1.0); // Candy definition
CBox candyBox(7.0, 4.5, 2.0); // Candy box definition
CBox carton(30.0, 18.0, 18.0); // Carton definition
// Calculate candies per candy box
int numCandies = candyBox/candy;
// Calculate candy boxes per carton
int numCboxes = carton/candyBox;
// Calculate wasted carton space
double space = carton%candyBox;
cout << endl
<< "There are " << numCandies
<< " candies per candy box"
<< endl
<< "For the standard boxes there are " << numCboxes
<< " candy boxes per carton " << endl << "with "
<< space << " cubic inches wasted.";
cout << endl << endl << "CUSTOM CANDY BOX ANALYSIS (No Waste)";
// Try the whole range of custom candy boxes
for(double length = 3.0 ; length <= 7.5 ; length += 0.5)
for(double width = 3.0 ; width <= 5.0 ; width += 0.5)
for(double height = 1.0 ; height <= 2.5 ; height += 0.5)
{
// Create new box each cycle
CBox tryBox(length, width, height);
if(carton%tryBox < tryBox.Volume() &&
tryBox % candy == 0.0 && tryBox/candy >= 30)
cout << endl << endl
<< "Trial Box L = " << tryBox.GetLength()
<< " W = " << tryBox.GetWidth()
<< " H = " << tryBox.GetHeight()
<< endl
<< "Trial Box contains " << tryBox / candy << " candies"
<< " and a carton contains " << carton / tryBox
<< " candy boxes.";
}
cout << endl;
return 0;
}

//************************************************** *****
// BoxOperators.h - Declarations for global box operators
#pragma once


bool operator>(const double& value, const CBox& aBox);
bool operator<(const double& value, const CBox& aBox);
bool operator>(const CBox& aBox, const double& value);
bool operator<(const CBox& aBox, const double& value);
bool operator>=(const double& value, const CBox& aBox);
bool operator<=(const double& value, const CBox& aBox);
bool operator>=(const CBox& aBox, const double& value);
bool operator<=(const CBox& aBox, const double& value);
bool operator==(const double& value, const CBox& aBox);
bool operator==(const CBox& aBox, const double& value);
CBox operator*(int n, const CBox& aBox);
double operator%(const CBox& aBox, const CBox& bBox);

//************************************************
// BoxOperators.cpp
// CBox object operations that don’t need to access private members
#include "Box.h"

// Function for testing if a constant is > a CBox object
bool operator>(const double& value, const CBox& aBox)
{ return value > aBox.Volume(); }
// Function for testing if a constant is < CBox object
bool operator<(const double& value, const CBox& aBox)
{ return value < aBox.Volume(); }
// Function for testing if CBox object is > a constant
bool operator>(const CBox& aBox, const double& value)
{ return value < aBox; }
// Function for testing if CBox object is < a constant
bool operator<( const CBox& aBox, const double& value)
{ return value > aBox; }
// Function for testing if a constant is >= a CBox object
bool operator>=(const double& value, const CBox& aBox)
{ return value >= aBox.Volume(); }
// Function for testing if a constant is <= CBox object
bool operator<=(const double& value, const CBox& aBox)
{ return value <= aBox.Volume(); }
// Function for testing if CBox object is >= a constant
bool operator>=( const CBox& aBox, const double& value)
{ return value <= aBox; }
// Function for testing if CBox object is <= a constant
bool operator<=( const CBox& aBox, const double& value)
{ return value >= aBox; }
// Function for testing if a constant is == CBox object
bool operator==(const double& value, const CBox& aBox)
{ return value == aBox.Volume(); }
// Function for testing if CBox object is == a constant
bool operator==(const CBox& aBox, const double& value)
{ return value == aBox; }
// CBox multiply operator n*aBox
CBox operator*(int n, const CBox& aBox)
{ return aBox * n; }
// Operator to return the free volume in a packed CBox
double operator%( const CBox& aBox, const CBox& bBox)
{ return aBox.Volume() - (aBox / bBox) * bBox.Volume(); }

//*************************************************
#pragma once


class CBox
{
public:
CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0); public:
public:
~CBox(void);
private:
// Lenght of a box in inches
double m_Length;
// Width of a box in inches
double m_Width;
// Height of a box in inches
double m_Height;
public:

double GetHeight(void) const
{
return m_Height;
}

double GetWidth(void) const
{
return m_Width;
}

double GetLength(void) const
{
return m_Length;
}

double Volume(void) const
{
return m_Length*m_Width*m_Height;
}
// overloaded additional operator
CBox operator+(const CBox& aBox) const;
// overloaded multiplication operator
CBox operator*(int n) const;
int operator/(const CBox& aBox) const;
};

//************************************************** *
#include "Box.h"
#include "BoxOperators.h"


CBox::CBox(double lv, double wv, double hv):m_Length(0)
{
lv = lv <= 0.0 ? 1.0 : lv; // Ensure positive
wv = wv <= 0.0 ? 1.0 : wv; // dimensions for
hv = hv <= 0.0 ? 1.0 : hv; // the object
m_Length = lv>wv ? lv : wv; // Ensure that
m_Width = wv<lv ? wv : lv; // length >= width
m_Height = hv;
}


CBox::~CBox(void)
{
}


// overloaded additional operator
CBox CBox::operator+(const CBox& aBox) const
{
// New object has larger length and width of the two,
// and sum of the two heights
return CBox(m_Length > aBox.m_Length ? m_Length : aBox.m_Length,
m_Width > aBox.m_Width ? m_Width : aBox.m_Width,
m_Height + aBox.m_Height);
}


// overloaded multiplication operator
CBox CBox::operator*(int n) const
{
if(n % 2)
return CBox(m_Length, m_Width, n*m_Height); // n odd
else
return CBox(m_Length, 2.0*m_Width, (n/2)*m_Height); // n even
}


int CBox::operator/(const CBox& aBox) const
{
int tc1 = 0; // Temporary for number in horizontal plane this way
int tc2 = 0; // Temporary for number in a plane that way
tc1 = static_cast<int>((m_Length / aBox.m_Length))*
static_cast<int>((m_Width / aBox.m_Width)); // to fit this way
tc2 = static_cast<int>((m_Length / aBox.m_Width))*
static_cast<int>((m_Width / aBox.m_Length)); // and that way
//Return best fit
return static_cast<int>((m_Height/aBox.m_Height)*(tc1>tc2 ? tc1 : tc2));
}
//that's all the code to the exercise "Ex8_08" PLEASE HELP ME!!!
//I WILL BE VERY GREATFUL


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ivor Horton's Visual C++ 2008(p620) Ex10_02 chanjackman BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 0 December 20th, 2011 10:44 PM
Best SDK for Beginning Visual C++ 2008, I. Horton OakJim Visual C++ 0 June 7th, 2008 04:13 PM
Visual C++ 6 by Ivor Horton Angelo2006 Visual C++ 0 January 4th, 2006 07:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.