View Single Post
Old 07-19-2006, 05:37 AM   #1 (permalink)
Timber
Registered User
 
Join Date: Jan 2005
Posts: 9
Timber is on a distinguished road
compilation error C2679. need guidance

Hi,
I am learning C++ and I am doing a project for school but however I am now stuck with 2 errors when I compile. I am not sure what I am doing wrong.
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

Would really appreciate if someone helps me out with this. Thanks


Code:
#include <iostream.h>
#include <string.h>
#include <iomanip.h>


//class cruiser template
class cruiser
{

char regNo[50];    
double engpower; 
char salesmanID[60] ; 
double importcost; 
double sellingprice; 


public:
static int numcommercial;
static int numprivate;


void setCruiser(char* ireg, double iengp, char* isalesman, double iimportcost, double isellprice)
 { strcpy(regNo, ireg);
   engpower = iengp;
   strcpy(salesmanID, isalesman);
   importcost = iimportcost;
   sellingprice = isellprice;
 }


void displaycruiser()
{
 cout << regNo << "\t"  << salesmanID << "\t"  << sellingprice ;

}

 char* get_regNo(void){ return regNo;}
};  // end of cruiser class 



class Private : public cruiser
{
double yearbuilt; 
double importtax; 
double ownershipfee;

public:

void setPrivate(double xyearbuilt, double ximporttax,double xownerfee, char* ireg, double iengp, 
char* isalesman, double iimportcost, double isellprice)
{

yearbuilt = xyearbuilt; 
importtax = ximporttax;
ownershipfee = xownerfee;

void setCruiser(char*ireg,double iengp, char *isalesman, double iimportcost, double isellprice);

}


void Private::displaypte()

         {      displaycruiser();
                cout << "\t" << "private" << "\t" << importtax << "\t" << ownershipfee << endl; 
          }
	
};



// Class Template for Commercial -----------------------------------------------

class Commercial: public cruiser
{    double maxloadcapacity;
     int numengines;
	 double regfees;

public:
	void setCommercial(double xmaxloadcapacity, int xnumengines, double xregfees, char* ireg, double 
iengp, char* isalesman, double iimportcost, double isellprice)
{  
maxloadcapacity = xmaxloadcapacity;
numengines = xnumengines;
regfees= xregfees;

          setCruiser(ireg, iengp,  isalesman, iimportcost,isellprice);
}

	void Commercial:: displaycc()
  {      displaycruiser();
cout << "\t" << "commercial" << "\t" << numengines << "\t" << regfees  << endl; 
 }
};


int cruiser:: numcommercial = 0;
int cruiser:: numprivate = 0;

int main()
{
int g,j,num,type, choice;
char xregNo[30];
double xengpower;
char xsalesmanID[30] ;
double ximportcost;
double xsellingprice;
double xyearbuilt;
double ximporttax;
double xownerfee;
double xmaxloadcapacity;
int xnumengines, i=0;
double xregfees;
double comA, comB;
double totalcount = 0;



Private pte[100];
Commercial cc[100];

	while (choice != 5)
	{     cout << endl;
		cout << "1. Add a new sales transaction" << endl;
		cout << "2. Update an existing transaction" << endl;
		cout << "3. Generate Sales Transaction Report" << endl;
		cout << "4. Generate Sales Summary" << endl;
		cout << "5. Exit" << endl;
		cout << "Please choose: ";
		cin >> choice;
		cin.ignore(1);

		switch (choice)
		{
		case 1 :
			  cout << "Enter type of vehicle: 1-Private 2-Commercial";
			  cin >> type;  // user select type = 1 for private type = 2 for commercial.
			  cin.ignore(1);
     if (type == 1)
	 
	 { 

        cout << "Enter Registration No:"; 
        cin >> xregNo; 
        cout << "Enter Engine Power:"; 
        cin >> xengpower; 
        cout << "Enter salesman ID:"; 
		cout << "Enter Import cost No:"; 
        cin >> ximportcost; 
	    cout << "Enter selling price:"; 
        cin >>xsellingprice; 
		cout << "Enter year of built:"; 
        cin >>xyearbuilt; 
		cout << "Enter ownership fee:"; 
        cin >>xownerfee;
				  
//prompt for yearbuilt, ownership fee and store in variables declared in the main (above).
 // based on importcost and yearbuilt, calculate final import tax (see question paper for the conditions
            		
pte[cruiser::numprivate].setPrivate(xyearbuilt, ximporttax, xownerfee,xregNo, xengpower, 
xsalesmanID, ximportcost, xsellingprice);
for (int g =0 ; g < cruiser::numprivate; g++);
 // add 1 to numprivate.
                      
 }
	 else
{ 

	    cout << "Enter Registration No:"; 
        cin >> xregNo; 
        cout << "Enter Engine Power:"; 
        cin >> xengpower; 
        cout << "Enter salesman ID:"; 
        cin >> xsalesmanID; 
        cout << "Enter Import cost No:"; 
        cin >> ximportcost; 
	    cout << "Enter selling price:"; 
        cin >>xsellingprice; 
		cout << "Enter maximum loading capacity:"; 
        cin >>xmaxloadcapacity; 
		cout << "Enter num of engines:"; 
        cin >>xnumengines; 
	

//prompt for all the Cruiser's (parent class) attributes and store in variables declared in the main (above).
//prompt for max load capcity, number of engines 
// based on number of engines and import cost, calculate the registration fees  //remember that registration fee has 2 components, comA and comB.		
				
xregfees = comA + comB;


cc[cruiser::numcommercial].setCommercial(xmaxloadcapacity, xnumengines,  xregfees, xregNo, 
xengpower, xsalesmanID, ximportcost, xsellingprice);
for (int j =0 ; j < cruiser::numcommercial; j++);
// add 1 to numcommercial.
                       
}
break;

case 2:    //edit
cout << "Select (1) Private or (2) Commercial to edit";
cin >>type;
cin.ignore(1);
                       

 if (type == 1) 
{
  for (int y =0 ; y < cruiser::numprivate; y++)             // this will display out all the registration number of private cruisers.
 cout << "("<< y << ")" << pte[y].get_regNo() << endl;

 cout << "select number to update; 0-" << cruiser::numprivate; // user will then select the index for update.
   cin >>num; 
  //-------------------------------------
  //prompt for all the Cruiser's (parent class) attributes.
//----------------------------------       
//prompt for yearbuilt, ownership fee and store in variables declared in the main (above).
  // based on importcost and yearbuilt, calculate final import tax 
            
pte[num].setPrivate(xyearbuilt, ximporttax, xownerfee,xregNo, xengpower, xsalesmanID, ximportcost, 
xsellingprice);
                      
}
else //type =2  commercial selected
{   
for (int t =0 ; t < cruiser::numcommercial; t++)
   cout << "("<< t << ")" << cc[t].get_regNo() << endl;

cout << "select number to update; 0-" << cruiser::numcommercial;
  cin >>num; 


// based on number of engines and import cost, calculate the registration fees (see question 
//paper for //conditions. remember that registration fee has 2 components, comA and comB.		
xregfees = comA + comB;

cc[num].setCommercial(xmaxloadcapacity, xnumengines,  xregfees,xregNo, xengpower, 
xsalesmanID,ximportcost, xsellingprice);

                       
}
break;

case 3:

  cout <<   "   TOMCAT CRUISER DEALING CO. PTE LTD " << endl;
  cout << " SALES TRANSACTIONS Report " << endl;
  cout << " Reg.No| SalesmanID |Sprice |ImportCost |Import tax/num eng|fees" << endl;  
  cout << endl;
if (cruiser::numprivate > 0)
{

	for (int g =0 ; g < cruiser::numprivate; g++)            
 
		pte[g].displaypte();

		cout << "("<< g << ")" << pte[g].displaypte()<< endl; //use for loop can call the displaypte function, to display out each object of the pte array.
}

if (cruiser::numcommercial > 0)
{

for (int j =0 ; j < cruiser::numcommercial; j++)            
cout << "("<< j << ")" << cc[j].displaycc()<<endl; //use for loop can call the displaycc function, to display out each object of the cc array.
}

cout << endl;
cout << endl;
cout << "# of Private Cruisers Sold : " << cruiser::numprivate;
cout << endl;
cout << "# of Commercial Cruisers Sold : " << cruiser::numcommercial;
break;

default:
cout << "Invalid choice." << endl;
} // end switch
} // end while
return 0;
}   //end main

Last edited by redhead; 07-19-2006 at 06:20 AM.
Timber is offline   Reply With Quote