Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
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
Old 07-19-2006, 06:29 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
Does this ring a bell
Code:
.....
void Private::displaypte()
.....
void Commercial:: displaycc()
...
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.
}
....
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.
....
Plus there might be missing a starting '{' in that first for loop.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-21-2006, 06:11 AM   #3 (permalink)
Timber
Registered User
 
Join Date: Jan 2005
Posts: 9
Timber is on a distinguished road
I'm not sure where the problem is I don't even know what the error mean
Though I know my for loop is suspicious...Is it some attributes I need to send to 'displaypte' .
Timber is offline   Reply With Quote
Old 07-21-2006, 09:37 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
1) Code changed to ISO C++.
2) Formatting changed to ANSI style.
3) Added colored syntax.
4) Formatted to line-break at max 80 characters.
5) Added crucial hints in main().

Code:
#include <iomanip>
#include <iostream>
#include <cstring> //old style string handling

using namespace std; //for brevity

//class cruiser template
class cruiser
{
private:
  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
{
private:
  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
{
private:
  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) // <<---- choice never initialized
  {     
    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;  // type = 1 = private | type = 2 = 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); //<< ----- ximporttax never initialized
        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; //comA & comB never initialized

        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) 
      {
        //this will display out all the registration number of 
        //private cruisers.
        for (int y =0 ; y < cruiser::numprivate; y++)
        {
          cout << "("<< y << ")" << pte[y].get_regNo() << endl;
        }
        // user will then select the index for update.
        cout << "select number to update; 0-" << cruiser::numprivate;
        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 |" ;
      cout << "Import tax/num eng|fees" ;
      cout << endl << endl;
      if (cruiser::numprivate > 0)
      {

        for (int g =0 ; g < cruiser::numprivate; g++)
        {
          pte[g].displaypte();
        }
        //use for loop can call the displaypte function, 
        //to display out each object of the pte array.
        //--->>> //cout << "("<< g << ")" << pte[g].displaypte()<< endl;
      }

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

      cout << endl << 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;
}
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need guidance regarding a program j.gohel Java 2 06-02-2005 11:54 AM
New Microsoft Security Service to Offer Timely Guidance redhead Code Newbie News 0 05-09-2005 02:44 AM
compilation error i like c++ Standard C, C++ 1 02-21-2005 10:39 PM
Compilation errors. liguorir Standard C, C++ 2 05-23-2004 06:21 PM


All times are GMT -8. The time now is 03:59 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting