My assignment is to create a definition of the class Box and a structure definition.

The class definition needs the following:
Data Member Data Type
boxNumber int
boxType int
boxLength float
boxWidth float
boxHeight float

boxArea float
boxCost float
boxPrice float
boxProfit float

boxFile fstream //Dont include boxFile yet.

Member Functions
setBoxFile - sets the boxFile reference variable.
addBox - Adds a new box to the box file.
findBox - Updates records in the box file.

and a get and set function for each of the class attributes.

My teacher said not to worry about the Member Functions yet. Not covered.

I used an example of a class called Time that i found in my textbook.
the set function example:
void setTime( int, int, int);

Im pretty sure i defined the get and set functions in the right way. Im confused about how using upper and lower case in the class and structure makes a difference.

#ifndef BOX_CLASS
#define BOX_CLASS

struct BoxData
	int boxNumber;     // Allow for up to 100 boxes
	int boxType;       // box type (1 to 4).
	float boxLength;
	float boxWidth;
	float boxHeight;
}; // end struct Box

class Box {

public:  //boxdata

	Box( ); // constructor function
//sets BoxData variables.
	void setBoxNumber(int);
	void setBoxType(int);
	void setBoxLength(float);
	void setBoxWidth(float);
	void setBoxHeight(float);

//gets BoxData ( 5 variables) and (4 functions) - used to return values.
	int getBoxNumber();
	int getBoxType();
	float getBoxLength();
	float getBoxWidth();
	float getBoxHeight();
	float getboxArea();
	float getboxCost();
	float getboxPrice();
	float getboxProfit();

	bool findBox(int);   // Finds a particular box in the box file.
	void setBoxFile(int); // sets the boxFile reference variable.
	bool addBox(int);	// Adds a new box to the box file.
	bool updateBox(int);	// Updates records in the box file.
	//boxFile fstream


	float boxArea;
	float boxCost;
	float boxPrice;
	float boxProfit;

}; //end class Box


//main.cpp starts here

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

#include "Box.h" //include definition of class 

int main ()
	Box x; // instantiate object x of class Box

		cout << "Choose a box type between ( 1 - 4 ) or 0 to exit: " << x.getBoxType;

	return 0;

i tried to create a file to test it in but i dont know what im doing wrong.

It showed 3 errors:
(21) : warning C4761: integral size mismatch in argument; conversion supplied
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall Box::getBoxType(void)" (?getBoxType@Box@@QAEHXZ)
main.obj : error LNK2001: unresolved external symbol "public: void __thiscall Box::setBoxType(int)" (?setBoxType@Box@@QAEXH@Z)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Box::Box(void)" (??0Box@@QAE@XZ)
Debug/main.exe : fatal error LNK1120: 3 unresolved externals

Did you define the member functions? That looks like the problem to me...

something like:

         //my constructor code here
This article has been dead for over six months. Start a new discussion instead.