Overloading class operators

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 3635 Views - Last Post: 19 February 2009 - 08:19 AM Rate Topic: -----

#1 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Overloading class operators

Posted 17 February 2009 - 03:45 PM

I'm supposed to use my professor's shell program to create a program that implements arithmetic operators like +, -, * and / as friend functions of Jar Type. It also is supposed to implement relational operators. Basically, the output, after what I already have below, should be:

output said:

Reading in data to a JarType, please enter integer data: 99
Data read and assigned to Jar1 was: 99

Testing output operations <<
Jar1 = This jar contains: 99 items
Jar2 = This jar contains: 15 items
Jar3 = This jar contains: 3 items


Here is the code so far:

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <cmath>
#include <cstdlib>


class JarType {
  public:
	// CONSTRUCTORS
	JarType() { numUnits = 0; }	 // default constructor
	  // POST: #units in jar is 0

	JarType(int n) { numUnits = n; }
	// POST: #units in jar is n and n >=0

  // MODIFICATION member functions
	void Add(int n) { numUnits += n; }
	// PRE:  n>= 0
	// POST: n units have been added to jar
 
  // CONST member functions which allow you to view data
	int Quantity () const  { return numUnits; }
  // PRE:  n>= 0
  // POST: returns number of units assigned to instance of JarType

 friend  JarType operator +(const JarType& firstJar, const JarType& secondJar );
 JarType operator -(const JarType& secondJar );

 friend  JarType operator *(const JarType& firstJar, const JarType& secondJar );
 JarType operator /( const JarType& secondJar );

 friend ostream& operator << (ostream& outputStream, const JarType& AJar);
 friend istream& operator >> (istream& inputStream, JarType& AJar);
	
  bool JarType ::operator == ( JarType otherjar) const;
  bool JarType ::operator < ( JarType otherjar) const;
  bool JarType ::operator != ( JarType otherjar) const;
  bool JarType ::operator > ( JarType otherjar) const;
 
  private:
	 int  numUnits;
  };

void main()
{
   JarType Jar1, Jar2 (15), Jar3 (3);

   cout << "Testing addition of two jars: ";
   Jar1 = Jar2 + Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 = "<< Jar3.Quantity()<<  "; Jar2 + Jar3 = " 
		 << Jar1.Quantity()<< endl << endl;

   cout << "\nTesting adding an integer to a jar object: ";
   Jar1 = Jar2 +5;
   cout << "  Jar2 = " << Jar2.Quantity() << "; Jar2 + 5 = "  << Jar1.Quantity()<< endl;

   cout << "\nTesting adding a jar object to an integer: ";
   Jar1 = 13 + Jar2;
   cout << " 13 + Jar2 = " << Jar1.Quantity()<< endl<< endl;

	cout << "Testing subtraction of two jars: ";
	Jar1 = Jar2 - Jar3;
	cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 = "<< Jar3.Quantity()<<  "; Jar2 - Jar3 = " 
		 << Jar1.Quantity() << endl<< endl;

   cout << "Testing Multiplication of two jars: ";
   Jar1 = Jar2 * Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 =" <<  Jar3.Quantity()
		<< ", Jar2 * Jar3 = "  << Jar1.Quantity() << endl<< endl;

   Jar1 = Jar2 * 2;
   cout << "  Jar2 = " << Jar2.Quantity() << " * 2 = " << Jar1.Quantity() << endl<< endl;

   Jar1 = 3 *  Jar2;
   cout << "  Jar2 = " << Jar2.Quantity() << ";  3 * Jar2 = " << Jar1.Quantity() << endl<< endl;

   cout << "Testing Division of two jars: ";
   Jar1 = Jar2 / Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << "  Jar3 = " << Jar3.Quantity()
		<< " Jar2 / Jar3 = " << Jar1.Quantity() << endl;

   cout << "\nRelational operators with  Jar1 = " << Jar1.Quantity()
		<< "  and Jar2 = " << Jar2.Quantity()  << endl;

   cout << "Testing < operator: ";
   if ( Jar1 < Jar2 )
	  cout << "Jar1 < Jar2\n";
   else
	  cout << "Jar1 not less than Jar2\n";

   cout << "Testing != operator: ";
   if ( Jar1 != Jar2)
	  cout << "Jar1 NOT equal to Jar2\n";
   else
	  cout << "Jar1 equals Jar2\n";

   cout << "Testing > operator: ";
   if ( Jar1 > Jar2)
	  cout << "Jar1 > Jar2\n";
   else
	  cout << "Jar1 NOT > Jar2\n";
 
   cout << "\nReading in data to a JarType, please enter integer data: ";
   cin  >> Jar1;
   cout << "\nData read and assigned to Jar1 was: ";
   cout << Jar1.Quantity();
 
  cout << "\n\nTesting output operations <<\nJar1 = " << Jar1 
	   << "Jar2 = " << Jar2 << "Jar3 = " << Jar3 << endl;

  cout << "\nThe end of CSC 275 Program 3!!"<< endl << endl;
system("pause");
  return;

} // end main

// This module exports a JarType ADT
//============================================
// Private members of class:  int numUnits

////////////////////////////////////////////////////////////////////////////
/////////////////  Relational operations <, >, ==, & != implementations
//////////////////////////////////////////////////////////////////////////
	bool JarType ::operator == ( JarType otherjar) const
	  {
		  return ( numUnits == otherjar.numUnits );
	  }


I can't even get this thing to compile properly. Any help? Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Overloading class operators

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 17 February 2009 - 04:16 PM

First, it isn't compiling because you're missing the definition of most of the functions.

For the arithmetic operators you only need a const reference to the second class object:

friend operator +(const JarType& secondJar)
{
	numUnits += secondJar.numUnits;
}
//so on and so forth



If you're going to add two class objects and assign to another you're going to need a copy constructor as well.


edit: i'm working a full snippet example, need a few minutes

This post has been edited by KYA: 17 February 2009 - 04:27 PM

Was This Post Helpful? 0
  • +
  • -

#3 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 17 February 2009 - 04:55 PM

Apologies for the double post:

#include <iostream>
using namespace std;

class JarType {
private:
	int numUnits;
public:
	JarType()				{ numUnits = 0; };
	JarType(int n)			{ numUnits = n; };
	int getUnits()			{ return numUnits;};

	JarType operator +(const JarType& secondJar)
	{
		JarType temp;
		temp.numUnits = numUnits + secondJar.numUnits;
		return temp;
	}

	void operator =(const JarType& secondJar)
	{
		numUnits = secondJar.numUnits; //assign data member from one to another
	}
};
int main()
{
	JarType jarOne, jarTwo(10), jarThree(15);
	jarOne = jarTwo;
	cout << jarOne.getUnits()		<< endl; //assignment operator jarOne.numUnits now equals 10
	jarOne = (jarTwo + jarThree);
	cout << jarOne.getUnits()		<< endl; // addition operator jarOne.numUnits now equals 25
	return 0;
}



Hope that helps.


EDIT: For further reading, I just wrote this

This post has been edited by KYA: 17 February 2009 - 05:39 PM

Was This Post Helpful? 0
  • +
  • -

#4 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 03:10 PM

Thanks so much! Unfortunately, my prof won't allow us to edit her source code (what I posted above was pretty much what she gave us), so I can't really implement what you suggested. So I added things as she instructed, and this is what I have (and it still won't compile).

#include <iostream>
using namespace std;
#include <cmath>
#include <cstdlib>


class JarType {
  public:
	// CONSTRUCTORS
	JarType() { numUnits = 0; }	 // default constructor
	  // POST: #units in jar is 0

	JarType(int n) { numUnits = n; }
	// POST: #units in jar is n and n >=0

  // MODIFICATION member functions
	void Add(int n) { numUnits += n; }
	// PRE:  n>= 0
	// POST: n units have been added to jar
 
  // CONST member functions which allow you to view data
	int Quantity () const  { return numUnits; }
  // PRE:  n>= 0
  // POST: returns number of units assigned to instance of JarType

 friend  JarType operator +(const JarType& firstJar, const JarType& secondJar );
 JarType operator -(const JarType& secondJar );

 friend  JarType operator *(const JarType& firstJar, const JarType& secondJar );
 JarType operator /( const JarType& secondJar );

 friend ostream& operator << (ostream& outputStream, const JarType& AJar);
 friend istream& operator >> (istream& inputStream, JarType& AJar);
	
  bool JarType ::operator == ( JarType otherjar) const;
  bool JarType ::operator < ( JarType otherjar) const;
  bool JarType ::operator != ( JarType otherjar) const;
  bool JarType ::operator > ( JarType otherjar) const;
 
  private:
	 int  numUnits;
  };

void main()
{
   JarType Jar1, Jar2 (15), Jar3 (3);

   //printHeader (); // Insert the appropriate name of your header function here
   
   cout << "Testing addition of two jars: ";
   Jar1 = Jar2 + Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 = "<< Jar3.Quantity()<<  "; Jar2 + Jar3 = " 
		 << Jar1.Quantity()<< endl << endl;

   cout << "\nTesting adding an integer to a jar object: ";
   Jar1 = Jar2 +5;
   cout << "  Jar2 = " << Jar2.Quantity() << "; Jar2 + 5 = "  << Jar1.Quantity()<< endl;

   cout << "\nTesting adding a jar object to an integer: ";
   Jar1 = 13 + Jar2;
   cout << " 13 + Jar2 = " << Jar1.Quantity()<< endl<< endl;

	cout << "Testing subtraction of two jars: ";
	Jar1 = Jar2 - Jar3;
	cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 = "<< Jar3.Quantity()<<  "; Jar2 - Jar3 = " 
		 << Jar1.Quantity() << endl<< endl;

   cout << "Testing Multiplication of two jars: ";
   Jar1 = Jar2 * Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << ",  Jar3 =" <<  Jar3.Quantity()
		<< ", Jar2 * Jar3 = "  << Jar1.Quantity() << endl<< endl;

   Jar1 = Jar2 * 2;
   cout << "  Jar2 = " << Jar2.Quantity() << " * 2 = " << Jar1.Quantity() << endl<< endl;

   Jar1 = 3 *  Jar2;
   cout << "  Jar2 = " << Jar2.Quantity() << ";  3 * Jar2 = " << Jar1.Quantity() << endl<< endl;

   cout << "Testing Division of two jars: ";
   Jar1 = Jar2 / Jar3;
   cout << "  Jar2 = " << Jar2.Quantity() << "  Jar3 = " << Jar3.Quantity()
		<< " Jar2 / Jar3 = " << Jar1.Quantity() << endl;

   cout << "\nRelational operators with  Jar1 = " << Jar1.Quantity()
		<< "  and Jar2 = " << Jar2.Quantity()  << endl;

   cout << "Testing < operator: ";
   if ( Jar1 < Jar2 )
	  cout << "Jar1 < Jar2\n";
   else
	  cout << "Jar1 not less than Jar2\n";

   cout << "Testing != operator: ";
   if ( Jar1 != Jar2)
	  cout << "Jar1 NOT equal to Jar2\n";
   else
	  cout << "Jar1 equals Jar2\n";

   cout << "Testing > operator: ";
   if ( Jar1 > Jar2)
	  cout << "Jar1 > Jar2\n";
   else
	  cout << "Jar1 NOT > Jar2\n";
 
   cout << "\nReading in data to a JarType, please enter integer data: ";
   cin  >> Jar1;
   cout << "\nData read and assigned to Jar1 was: ";
   cout << Jar1.Quantity();
 
  cout << "\n\nTesting output operations <<\nJar1 = " << Jar1 
	   << "Jar2 = " << Jar2 << "Jar3 = " << Jar3 << endl;

  cout << "\nThe end of CSC 275 Program 3!!"<< endl << endl;
system("pause");

} // end main

// This module exports a JarType ADT
//============================================
// Private members of class:  int numUnits

////////////////////////////////////////////////////////////////////////////
/////////////////  Relational operations <, >, ==, & != implementations
//////////////////////////////////////////////////////////////////////////
	bool JarType ::operator == ( JarType otherjar) const
	  {
		  return ( numUnits == otherjar.numUnits );
	  }
	bool JarType ::operator < (JarType otherjar) const
	  {
		  return (numUnits < otherjar.numUnits);
		  }
	bool Jartype ::operator > (JarType otherjar) const
		 {
				 return (numUnits > otherjar.numUnits);
				 }
	bool JarType ::operator & (JarType otherjar) const
		 {
				 return ( numUnits & otherjar.numUnits);
				 }
	bool JarType ::operator != (JarType otherjar) const
		 {
				 return (numUnits != otherjar.numUnits);
				 }




///////////////////////////////////////////////////////////////////////////
//////////////  Arithmetic Operators Defined //////////////////////////////
//////////////////////////////////////////////////////////////////////////

//friend  JarType operator +(const JarType& firstJar, const JarType& secondJar );
friend JarType ::operator +(JarType firstJar, JarType secondJar) const
			 {
						return (firstJar + secondJar);
						}
						
friend JarType ::operator -(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar - secondJar);
			 }
			 
friend JarType ::operator *(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar * secondJar);
			 }
			 
friend JarType ::operator /(JarType firstJar, JarType secondJar) const
	  {
			  return (firstJar / secondJar);
			  }		



I know I'm obviously doing a lot wrong here, but I can't seem to track down what it is. :/
Was This Post Helpful? 0
  • +
  • -

#5 PostulateMan   User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 14-September 08

Re: Overloading class operators

Posted 18 February 2009 - 03:22 PM

So your professor wrote the definitions and you wrote the implementation, correct?

The problem is that the friend functions pass in two const objects and you're trying to do the operation you want on the objects together. For example, on operator+, shouldn't you be adding:

firstJar.numUnits + secondJar.numUnits;


Was This Post Helpful? 0
  • +
  • -

#6 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 03:33 PM

View PostPostulateMan, on 18 Feb, 2009 - 02:22 PM, said:

So your professor wrote the definitions and you wrote the implementation, correct?

The problem is that the friend functions pass in two const objects and you're trying to do the operation you want on the objects together. For example, on operator+, shouldn't you be adding:

firstJar.numUnits + secondJar.numUnits;



Yes, I wrote this bit of code:

bool JarType ::operator < (JarType otherjar) const
	  {
		  return (numUnits < otherjar.numUnits);
		  }
	bool Jartype ::operator > (JarType otherjar) const
		 {
				 return (numUnits > otherjar.numUnits);
				 }
	bool JarType ::operator & (JarType otherjar) const
		 {
				 return ( numUnits & otherjar.numUnits);
				 }
	bool JarType ::operator != (JarType otherjar) const
		 {
				 return (numUnits != otherjar.numUnits);
				 }




///////////////////////////////////////////////////////////////////////////
//////////////  Arithmetic Operators Defined //////////////////////////////
//////////////////////////////////////////////////////////////////////////

//friend  JarType operator +(const JarType& firstJar, const JarType& secondJar );
friend JarType ::operator +(JarType firstJar, JarType secondJar) const
			 {
						return (firstJar.numUnits + secondJar.numUnits);
						}
						
friend JarType ::operator -(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar.numUnits - secondJar.numUnits);
			 }
			 
friend JarType ::operator *(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar.numUnits * secondJar.numUnits);
			 }
			 
friend JarType ::operator /(JarType firstJar, JarType secondJar) const
	  {
			  return (firstJar.numUnits / secondJar.numUnits);
			  }		


I made the changes you suggested, but this thing is still a mess. I did end up changing void main to int main because the compiler was giving me issues with that. Now the compiler only dislikes the code I posted above.
Was This Post Helpful? 0
  • +
  • -

#7 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 18 February 2009 - 03:49 PM

It would help if you posted the error messages, but I can see one at a quick glance:

friend JarType ::operator +(JarType firstJar, JarType secondJar) const
{
		  return (firstJar.numUnits + secondJar.numUnits);
}



That snippet has no return type. I'm guessing you don't want to return an int correct? You want to return an object with those properties right?

JarType& JarType ::operator +(JarType firstJar, JarType secondJar) const
{
		 JarType temp;
		 temp.numUnits = firstJar.Quantity() + secondJar.Quantity();
		 return temp;
}


Was This Post Helpful? 0
  • +
  • -

#8 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 04:06 PM

OK, these are the errors I am getting:

Quote

Desktop\prog3.cpp:142: error: `Jartype' has not been declared

Desktop\prog3.cpp:143: error: non-member function `bool operator>(JarType)' cannot have `const' method qualifier
Desktop\prog3.cpp:143: error: `bool operator>(JarType)' must take exactly two arguments
Desktop\prog3.cpp: In function `bool operator>(JarType)':
Desktop\prog3.cpp:144: error: `numUnits' undeclared (first use this function)
Desktop\prog3.cpp:144: error: (Each undeclared identifier is reported only once for each function it appears in.)
Desktop\prog3.cpp:47: error: `int JarType::numUnits' is private
Desktop\prog3.cpp:144: error: within this context
Desktop\prog3.cpp: At global scope:
Desktop\prog3.cpp:147: error: no `bool JarType::operator&(JarType) const' member function declared in class `JarType'
Desktop\prog3.cpp:164: error: ISO C++ forbids declaration of `operator+' with no type
Desktop\prog3.cpp:164: error: can't initialize friend function `operator+'
Desktop\prog3.cpp:164: error: friend declaration not in class definition
Desktop\prog3.cpp:164: error: `int JarType::operator+(JarType, JarType)' must take either zero or one argument
Desktop\prog3.cpp:164: error: no `int JarType::operator+(JarType, JarType) const' member function declared in class `JarType'

Desktop\prog3.cpp:169: error: ISO C++ forbids declaration of `operator-' with no type
Desktop\prog3.cpp:169: error: can't initialize friend function `operator-'
Desktop\prog3.cpp:169: error: friend declaration not in class definition
Desktop\prog3.cpp:169: error: `int JarType::operator-(JarType, JarType)' must take either zero or one argument
Desktop\prog3.cpp:169: error: prototype for `int JarType::operator-(JarType, JarType) const' does not match any in class `JarType'
Desktop\prog3.cpp:33: error: candidate is: JarType JarType::operator-(const JarType&)
Desktop\prog3.cpp:174: error: ISO C++ forbids declaration of `operator*' with no type
Desktop\prog3.cpp:174: error: can't initialize friend function `operator*'
Desktop\prog3.cpp:174: error: friend declaration not in class definition
Desktop\prog3.cpp:174: error: `int JarType::operator*(JarType, JarType)' must take either zero or one argument
Desktop\prog3.cpp:174: error: no `int JarType::operator*(JarType, JarType) const' member function declared in class `JarType'
Desktop\prog3.cpp:179: error: ISO C++ forbids declaration of `operator/' with no type
Desktop\prog3.cpp:179: error: can't initialize friend function `operator/'
Desktop\prog3.cpp:179: error: friend declaration not in class definition
Desktop\prog3.cpp:179: error: `int JarType::operator/(JarType, JarType)' must take exactly one argument
Desktop\prog3.cpp:179: error: prototype for `int JarType::operator/(JarType, JarType) const' does not match any in class `JarType'
Desktop\prog3.cpp:36: error: candidate is: JarType JarType::operator/(const JarType&)

Was This Post Helpful? 0
  • +
  • -

#9 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 18 February 2009 - 04:32 PM

Look at the post above, most of these can be resolved by adding the correct (or at least some) return type, verifying the list (which I imagine was taken from JarType.cpp) against the actual class definition, and using the getter function rather then trying to access the private data member. Quantity() is the accessor function.
Was This Post Helpful? 0
  • +
  • -

#10 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 05:03 PM

OK, thanks. I'm not sure I quite understand what to do with it. I tried this:

friend JarType ::operator +(JarType firstJar, JarType secondJar) const
			 {
						return (firstJar.Quantity + secondJar.Quantity);
						}
						
friend JarType ::operator -(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar.Quantity - secondJar.Quantity);
			 }
			 
friend JarType ::operator *(JarType firstJar, JarType secondJar) const
	 {
			 return (firstJar.Quantity * secondJar.Quantity);
			 }
			 
friend JarType ::operator /(JarType firstJar, JarType secondJar) const
	  {
			  return (firstJar.Quantity / secondJar.Quantity);
			  }	  


As far as JarType is concerned, the only other C++ file I can find with this program is jarVerEq.cpp. This is the contents of that file:

#include<iostream>
#include "jareq.cpp"
using namespace std;

void main()
{
JarType Jar1, Jar2 (5), MyJar = JarType (20);
int amount;
system("cls");

cout << "\nAfter constructors called Jar1 quantity: "<< Jar1.Quantity()<< ", Jar2.Quantity(): "
	 << Jar2.Quantity()<< "\n";

if ( Jar1 == Jar2)
   cout << "\nAfter constructors called Jar1 & Jar2 equal\n";
else
   cout << "\nAfter constructors called Jar1 & Jar2 NOT EQUAL\n";

Jar2.Add (15);
cout << "\nAfter calls to Jar2.Add(15) Quantity = " << Jar2.Quantity() << endl;

cout<< "\nAfter assignment MyJar = Jar2;  ";
MyJar = Jar2;

if ( MyJar == Jar2 )
	cout << "MyJar == Jar2\n\n";
else
	cout << "\nMyJar not equal to Jar2\n\n";
}

Was This Post Helpful? 0
  • +
  • -

#11 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 18 February 2009 - 05:07 PM

Here:

friend JarType ::operator +(JarType firstJar, JarType secondJar) const
			 {
						return (firstJar.Quantity + secondJar.Quantity);
						}




Still has no return type.
Was This Post Helpful? 0
  • +
  • -

#12 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 05:25 PM

OK, I just have another question (my prof really didn't explain any of this that well). jarVerEq.cpp is the latest version of JarType (according to her), so should I be referring to jarVerEq rather than JarType in the main program?
Was This Post Helpful? 0
  • +
  • -

#13 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 18 February 2009 - 05:32 PM

You mean the class? I'm slightly confused. I would use the material given/required for the assignment.
Was This Post Helpful? 0
  • +
  • -

#14 tigerfan88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 16-January 09

Re: Overloading class operators

Posted 18 February 2009 - 05:37 PM

View PostKYA, on 18 Feb, 2009 - 04:32 PM, said:

You mean the class? I'm slightly confused. I would use the material given/required for the assignment.


I am as well. This is what she instructed:

Quote

You can insert the JarType prototype and implementation code within this main program, or you may choose to separate the JarType implementation into two files JarType.h and JarType.cpp, then include these within the main driver using an include directive. You are to build on the JarType we've been looking at in class. The lastest version of JarType named JarVereq.


I don't really get what she means with this. At all. :/
Was This Post Helpful? 0
  • +
  • -

#15 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,233
  • Joined: 14-September 07

Re: Overloading class operators

Posted 18 February 2009 - 05:39 PM

WTF is a JarType? I thought it was just some class given for the assignment. :\


edit: Is this some external library?

This post has been edited by KYA: 18 February 2009 - 05:40 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2