Questions about missing default parameters

I have a program that includes
//Package.h
#ifndef PACKAGE_H
#define PACKAGE_H

#include <string>
using std::string;

class Package
{
public:
Package(const string &, const string &, const string &, const string &, int = 0,
const string &, const string &, const string &, const string &, int = 0,
double = 0.0 , double = 0.0 );// top part is sender, middle is reciever, bottom is weight and price

private:
string senderName;
string senderAddress;
string senderCity;
string senderState;
int senderZip;

string recieverName;
string recieverAddress;
string recieverCity;
string recieverState;
int recieverZip;

double weight;
double price;
};//end of class package

#endif


and

//Package.cpp
#include <iostream>
using std::cout;

#include "Package.h" //package class definition

//constructor
Package::Package( const string &sName, const string &sAddress ,const string &sState, const string &sCity, int sZip, const string &reciverN, const string &recieverA , const string &recieverS, const string &recieverC, int rZip, double w, double p )
{
senderName = sName;
senderAddress = sAddress;
senderCity = sCity;
senderState = sSate;
senderZip = sZip;
recieverName = recieverN;
recieverAddress = recieverA;
recieverCity = recieverC;
recieverState = recieverS;
recieverZip = rZip;

weight = w;
price = p;
}//end of package constructor


and when I run the main function I get this error message

1>------ Build started: Project: HW4, Configuration: Debug Win32 ------
1>Compiling...
1>Package.cpp
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 6
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 7
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 8
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 9
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.cpp(13) : error C2065: 'sSate' : undeclared identifier
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.cpp(15) : error C2065: 'recieverN' : undeclared identifier
1>PackageMain.cpp
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 6
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 7
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 8
1>c:\users\john\documents\visual studio 2008\projects\hw4\hw4\package.h(11) : error C2548: 'Package::Package' : missing default parameter for parameter 9
1>Generating Code...
1>Build log was saved at "file://c:\Users\John\Documents\Visual Studio 2008\Projects\HW4\HW4\Debug\BuildLog.htm"
1>HW4 - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I can not figure out why parameters 6-9 are missing but all the others seem to work. Any insight as to what the problem might be will be much appreciated.

Respectfully
Jonoleth
You can't have a default parameter in the middle of the parameter list like that. Once you have a default parameter, all following parameters must have default parameters as well.

1
2
3
4
5
6
7
8
9
10
11
void good(
    int a,
    int b = 0,  // now that we have a default param
    int c = 0   // all parameters following must have a default
   );

void bad()
    int a,
    int b = 0,
    int c      // ERROR - needs a default param
   );
OH, Thank you Thank you Thank You! That has fixed it! You are wonderful!
Topic archived. No new replies allowed.