Click here to Skip to main content
15,911,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert const string& to CByteArray ? Pin
mmayur16-Feb-09 8:46
mmayur16-Feb-09 8:46 
GeneralRe: Convert const string& to CByteArray ? Pin
CPallini16-Feb-09 9:46
mveCPallini16-Feb-09 9:46 
GeneralRe: Convert const string& to CByteArray ? Pin
mmayur16-Feb-09 10:02
mmayur16-Feb-09 10:02 
GeneralRe: Convert const string& to CByteArray ? Pin
CPallini16-Feb-09 10:51
mveCPallini16-Feb-09 10:51 
GeneralRe: Convert const string& to CByteArray ? Pin
mmayur16-Feb-09 11:27
mmayur16-Feb-09 11:27 
GeneralRe: Convert const string& to CByteArray ? Pin
mmayur17-Feb-09 9:15
mmayur17-Feb-09 9:15 
AnswerRe: Convert const string& to CByteArray ? Pin
frx9616-Feb-09 16:29
frx9616-Feb-09 16:29 
Questionneed a minor help in my program [modified] Pin
tksrules16-Feb-09 4:20
tksrules16-Feb-09 4:20 
I have a code written as:-
#include<string>
#include <iostream>
#include <iomanip>

using namespace std;

// This class Package is the base class for two other classes, TwoDayPackage and OverNightPackage.//

class Package // begins class Package
{
public:
Package(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, double = 0.0, double = 0.0); // constructor

// set and get functions for sender
void setSendName(const string &);
string getSendName() const;

void setSendAdd(const string &);
string getSendAdd() const;

void setSendCity(const string &);
string getSendCity() const;

void setSendSt(const string &);
string getSendSt() const;

void setSendZip(const string &);
string getSendZip() const;

// set and get functions for recipient
void setRecName(const string &);
string getRecName() const;

void setRecAdd(const string &);
string getRecAdd() const;

void setRecipientCity(const string &);
string getRecipientCity() const;

void setRecSt(const string &);
string getRecSt() const;

void setRecZip(const string &);
string getRecZip() const;

void setWt(double);
double getWt() const;
void setShip(double);
double Package::getShip() const
{
return shipCost;
}

double Package::CalCost() const
{

return (wt*shipCost);
}

private:
string sendName;
string sendAdd;
string sendCity;
string sendState;
string sendZip;
string recName;
string recAdd;
string recCity;
string recState;
string recZip;
double wt;
double shipCost;
};
Package::Package(const string &sname, const string &saddress, const string &scity, const string &sstate, const string &szipcode, const string &rname, const string &raddress, const string &rcity, const string &rstate, const string &rzipcode, double wt, double shipCost)
{
sendName = sname;
sendAdd = saddress;
sendCity = scity;
sendState = sstate;
sendZip = szipcode;
recName = rname;
recAdd = raddress;
recCity = rcity;
recState = rstate;
recZip = rzipcode;
setWt(wt);
setShip(shipCost);
}

void Package::setSendName(const string &sname)
{
sendName = sname;
}

string Package::getSendName() const
{
return sendName;
}

void Package::setSendAdd(const string &saddress)
{
sendAdd = saddress;
}

string Package::getSendAdd() const
{
return sendAdd;
}
void Package::setSendCity(const string &scity)
{
sendCity = scity;
}

string Package::getSendCity() const
{
return sendCity;
}

void Package::setSendSt(const string &sstate)
{
sendState = sstate;
}

string Package::getSendSt() const
{
return sendState;
}

void Package::setSendZip(const string &szipcode)
{
sendZip = szipcode;
}

string Package::getSendZip() const
{
return sendZip;
}

void Package::setRecName(const string &rname)
{
recName = rname;
}

string Package::getRecName() const
{
return recName;
}

void Package::setRecAdd(const string &raddress)
{
recAdd = raddress;
}

string Package::getRecAdd() const
{
return recAdd;
}

void Package::setRecipientCity(const string &rcity)
{
recCity = rcity;
}

string Package::getRecipientCity() const
{
return recCity;
}

void Package::setRecSt(const string &rstate)
{
recState = rstate;
}

string Package::getRecSt() const
{
return recState;
}
void Package::setRecZip(const string &rzipcode)
{
recZip = rzipcode;
}

string Package::getRecZip() const
{
return recZip;
}

void Package::setWt(double wt)
{
wt = (wt < 0.0 ) ? 0.0 : wt;
}
double Package::getWt() const
{
return wt;
}
void Package::setShip(double shipCost)
{
shipCost = ( shipCost < 0.0) ? 0.0 : shipCost;
}




// This class TwoDayPackage is the first derived class from class Package.//

class TDP : public Package
{
public:
TDP(const string &, const string &, const string &, const string &, const string &, const string &,
const string &, const string &, const string &, const string &, double = 0.0, double = 0.0, double = 0.0); // constructor

void setFlatFee(double);
double getFlatFee() const;
double CalCost() const;

private:
double flatFee;
};


// This class OverNightPackage is the second derived class from class Package.//

class ONP : public Package
{
public:

ONP(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, double=0.0, double=0.0, double=0.0); // constructor

void setFee(double);
double getFee() const;
double CalCost() const;

private:
double fee;
};



// This is the test program.//

int main()
{
ONP box("name", "123 this Street", "boston", "ma", "12345", "receiver", "123 that street", "medford", "ma", "25341", 10.00, 1.50, .85);

TDP parcel("name2", "123 1st Street", "orlando", "fl", "56474", "receiver2", "833 2nd Street", "miami", "fl", "88472", 15.00, 1.05, 5.00);

cout << fixed << setprecision(2);

cout << "To ship a box with overnight delivery\n";
cout << "The sender " << box.getSendName()<< "\n";
cout << " " << box.getSendAdd() << "\n";
cout << " " << box.getSendCity() << " " << box.getSendSt() << " " << box.getSendZip() << "\n";


cout << "The recipient " << box.getRecName()<< "\n";
cout << " " << box.getRecAdd() << "\n";
cout << " " << box.getRecipientCity() << " " << box.getRecSt() << " " << box.getRecZip() << "\n";
cout << "The cost is $ " <<box.CalCost() << "\n";

cout << "\n\n";

cout << "To ship a parcel with 2 day delivery\n";
cout << "The sender " << parcel.getSendName()<< "\n";
cout << " " << parcel.getSendAdd() << "\n";
cout << " " << parcel.getSendCity() << " " << parcel.getSendSt() << " " << parcel.getSendZip() << "\n";


cout << "The recipient " << parcel.getRecName()<< "\n";
cout << " " << parcel.getRecAdd() << "\n";
cout << " " << parcel.getRecipientCity() << " " << parcel.getRecSt() << " " << parcel.getRecZip() << "\n";
cout << "The cost is $ "<<parcel.CalCost() << "\n";

system("pause");
return 0;
}

The calcost function needs some change as it is the source of error.Somebody help.

modified on Monday, February 16, 2009 12:15 PM

GeneralRe: need a minor help in my program Pin
Perspx16-Feb-09 4:26
Perspx16-Feb-09 4:26 
QuestionRe: need a minor help in my program Pin
David Crow16-Feb-09 6:18
David Crow16-Feb-09 6:18 
AnswerRe: need a minor help in my program Pin
tksrules16-Feb-09 6:22
tksrules16-Feb-09 6:22 
GeneralRe: need a minor help in my program Pin
David Crow16-Feb-09 6:39
David Crow16-Feb-09 6:39 
GeneralRe: need a minor help in my program Pin
tksrules16-Feb-09 6:42
tksrules16-Feb-09 6:42 
JokeRe: need a minor help in my program Pin
CPallini16-Feb-09 11:01
mveCPallini16-Feb-09 11:01 
QuestionRe: need a minor help in my program Pin
David Crow16-Feb-09 11:05
David Crow16-Feb-09 11:05 
AnswerRe: need a minor help in my program Pin
CPallini16-Feb-09 11:15
mveCPallini16-Feb-09 11:15 
GeneralRe: need a minor help in my program Pin
Rajesh R Subramanian16-Feb-09 18:34
professionalRajesh R Subramanian16-Feb-09 18:34 
GeneralRe: need a minor help in my program Pin
CPallini16-Feb-09 21:27
mveCPallini16-Feb-09 21:27 
Questionencryption and description functions in C++ on sunOS [modified] Pin
suresh_r16-Feb-09 1:46
suresh_r16-Feb-09 1:46 
AnswerRe: encryption and description functions in C++ on sunOS Pin
CPallini16-Feb-09 2:27
mveCPallini16-Feb-09 2:27 
AnswerRe: encryption and description functions in C++ on sunOS Pin
Stuart Dootson16-Feb-09 11:09
professionalStuart Dootson16-Feb-09 11:09 
GeneralRe: encryption and description functions in C++ on sunOS Pin
Rajesh R Subramanian16-Feb-09 18:38
professionalRajesh R Subramanian16-Feb-09 18:38 
GeneralRe: encryption and description functions in C++ on sunOS Pin
Stuart Dootson16-Feb-09 19:38
professionalStuart Dootson16-Feb-09 19:38 
GeneralRe: encryption and description functions in C++ on sunOS Pin
Rajesh R Subramanian16-Feb-09 22:48
professionalRajesh R Subramanian16-Feb-09 22:48 
GeneralRe: encryption and description functions in C++ on sunOS Pin
Stuart Dootson16-Feb-09 23:17
professionalStuart Dootson16-Feb-09 23:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.