[C++] Help with simple connection with header

Skilled Illusionist
Joined
Jul 12, 2008
Messages
303
Reaction score
3
Code:
Update the Fraction class given in the Lecture notes or as discussed in class meetings as follows, 
1.	Add your FIRST NAME to the name Fraction and use this as your updated class. For examples, if your first name is John then update the class name to be JohnFraction; if your first name is Smith then update the class name to be SmithFraction.
2.	Add and update all class constructors for your fraction class to handle the initialization appropriately. 
There must be as least 3 constructors of 
(i) 	default, 
(ii) 	copy, and 
(iii) 	convert taking on an int.
3.	Provide all get/set member functions for each private member data.
4.	Provide the following member functions,
a.	A member function add() to add the current fraction to a fraction given as an argument, and
b.	A member function subtract( ) to subtract a fraction given as an argument from the current fraction, and
c.	A member function multiply( ) to multiply the current fraction with  a fraction given as an argument, and
d.	A member function divide( ) to divide the current fraction by a fraction given as an argument , and
e.	A member function print() that will print the resulting fraction(s).
5.	Save the program as cis25Fall2009YourNameLab5CodeEx1.cpp, 
6.	Run and record the output of the program. 
(a) The output screen should have the following lines displayed before any other display or input can be seen,

Assignment Information -- 
  Assignment Number:  Lab 6, 
                      Exercise #1
  Written by:         Your Name
  Due Date:           Due Date

(b) Then, the output screen should be followed by a sample output as follows,

CREATE SOME REASONABLE FRACTION(S) HERE FIRST

***************************
*          MENU           *
*                         *
*  1. Calling add()       *
*  2. Calling subtract()  *
*  3. Calling multiply()  *
*  4. Calling divide()    *
*  5. Calling print()     *
*  6. Quit                *
*                         *
***************************
Select an option (use integer value only): 5

Calling print() – 

  REPLACE WITH YOUR CODE AND ACTUAL OUTPUT

***************************
*          MENU           *
*                         *
*  1. Calling add()       *
*  2. Calling subtract()  *
*  3. Calling multiply()  *
*  4. Calling divide()    *
*  5. Calling print()     *
*  6. Quit                *
*                         *
***************************
Select an option (use integer value only): 1

Calling add() – 

  REPLACE WITH YOUR CODE AND ACTUAL OUTPUT


Does anyone have any idea of how to start? >.< I have the header file, and stuff, but kinda confused what to put inside the header.
 
I've come up with
Code:
/**
 * Program Name: cis25Fall2010Lab6codeEx1.cpp
 * Written By:  Timmy
 * Discussion: Function Class and Operations
 */

#include <iostream>
#include "TimmyFraction.h"
using namespace std;

void printClassAssignInfo( void );
void menuOption();

int main() {

  TimmyFraction FracOnDemand;
  
  printClassAssignInfo();
  menuOption();


  return 0;
}

void printClassAssignInfo() {

  cout << "\nClass Information --"
       << "\nAssignment Information --"
       << "\n  Assignment Number:  Lab 6 Exercise #1"
       << "\n  Due Date:           Oct 28th, 2010\n" << endl;

  return;
}

void menuOption( void ) {
  int iOption;

  do{
    cout << "\n\t***************************\n"
		 << "\n\t*         MENU            *\n"
		 << "\n\t*                         *\n"
		 << "\n\t* 1. Calling add()        *\n"
         << "\n\t* 2. Calling subtract()   *\n"
         << "\n\t* 3. Calling multiply()   *\n"
         << "\n\t* 4. Calling divide()     *\n"
         << "\n\t* 5. Calling print()      *\n"
         << "\n\t* 6. Quit                 *\n"
         << "\n\t*                         *\n"
         << "\n\t***************************\n" << endl << endl;

    cout << " Select an option ( 1 - 6 ) : " ;
    cin >> iOption;     

    switch ( iOption ) {
      case 1:
         cout << "\t  Calling add() - "  << endl << endl;
		     FracOnDemand.add();
        break;
      case 2:
         cout << "\t  Calling subtract() - "  << endl << endl;
		     FracOnDemand.subtract();
        break;
      case 3:
         cout << "\t  Calling multiply() - "  << endl << endl;
		     FracOnDemand.multiply();
        break;
	    case 4:
	       cout << "\t  Calling divide() - "  << endl << endl;
		     FracOnDemand.divide();
		    break;
	    case 5:
	       cout << "\t  Calling print() - "  << endl << endl;
		     FracOnDemand.print();
	      break;
	    case 6:
	       cout << " Thank you for trying! " << endl;
		    break;
         default:
		     cout << " Wrong Option! Please try again." << endl;

    }
	FracOnDemand.~TimmyFraction();
  }while ( iOption != 6 );

  
 }


and for my header

Code:
/**
 *Filename:    TimmyFraction.h
 *Description: Specification file
 **/

#ifndef TimmyFRACTION_H
#define TimmyFRACTION_H

class TimmyFraction {
public:
	TimmyFraction();

	~TimmyFraction();

	int add();
	int subtract();
	int multiply();
	int divide();
	void print();
	  
private:
	int iA;
	int iB;
	int iResult;
	int iCheck;
	

};
#endif

I complied and I end up getting this error

Any help?

Code:
1>------ Build started: Project: Lab6, Configuration: Debug Win32 ------
1>Compiling...
1>cis25Fall20106codeEx1.cpp
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(60) : error C2065: 'FracOnDemand' : undeclared identifier
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(60) : error C2228: left of '.add' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(64) : error C2065: 'FracOnDemand' : undeclared identifier
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(64) : error C2228: left of '.subtract' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(68) : error C2065: 'FracOnDemand' : undeclared identifier
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(68) : error C2228: left of '.multiply' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(72) : error C2065: 'FracOnDemand' : undeclared identifier
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(72) : error C2228: left of '.divide' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(76) : error C2065: 'FracOnDemand' : undeclared identifier
1>c:\users\\downloads\cis25fall2010nlab6codeex1.cpp(76) : error C2228: left of '.print' must have class/struct/union
1>        type is ''unknown-type''
1>c:\users\\downloads\cis25fall2010lab6codeex1.cpp(85) : error C2065: 'FracOnDemand' : undeclared identifier
1>Build log was saved at "file://c:\Users\\Documents\Visual Studio 2008\Projects\Lab6\Lab6\Debug\BuildLog.htm"
1>Lab6 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
Back