need some help with the friend function that overloads the << operator heres my code thus far....

#ifndef PRODUCT
#define PRODUCT
#include <iostream>
using namespace std;

class CProduct
{
   private:
     int productID;              // 5-digit product ID number
     int manufactureID;           // 4-digit manufacturer's ID
     double price;           // wholesale price
     double markup;          // percent markup from wholesale, .nn

   public:
     CProduct(int pID=00000, int mID=0000, double n_price=0, double n_markup=0)   // default and explicit-value constructor
	 {
		 productID=pID;
		 manufactureID=mID;
		 price=n_price;
		 markup=n_markup;
	 }
	 
               
	 double retailPrice();    // RetailPrice Returns the retail price 
                           //  = wholesale price increased by markup

     bool operator<(CProduct x);   // overloaded < operator  
                           // Receives a CProduct object
                           // Returns true iff this product's ID number < 
                           //    the argument's product ID number

     friend ostream& operator<<(ostream& a, CProduct b);   // overloaded friend output << operator	
    		 		  
};
#endif


//----------------heres my cpp file--------------------------
#include "Product.h"
#include <iostream>
using namespace std;

double CProduct::retailPrice()
{

	return price - (price * markup/100);
}

bool CProduct::operator<(CProduct x)
{
	if(productID < x.productID)
		return true;
	else
		return false;
}

ostream& operator<<(ostream& a, CProduct b)
{
	a << b.productID;
	a << b.manufactureID;
	a << b.price;
	a << b.markup;
}

//-----------------------heres my main to test the functions----------------------

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

int main()
{
	CProduct product1(12345,1234,25.03,12);//product 1 constr
	CProduct product2(67891,5678,15,35);//product 2 constr
	if(product1<product2)
		cout << product1;
	else if(product2<product1)
		cout << product2;
	
		return 0;
}

if you see any other problems please let me know

What seems to be the issue? Your output isn't formatted at all, but other than that, I can't discern what your issue may be.

figured it out all i forgot was the "return a;" haha. thanks for looking at my code though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.