Solved

Debug Help

Posted on 2002-04-12
11
355 Views
Last Modified: 2012-06-21
Any help debugging this code would be great!

#include<iostream.h>
#include<conio.h>
class Dress
 {
  private:
   char material[20];
   int size;
   char style[10];
   double price;

  public:
    Dress(const char mtrl[] = "cotton",const char stl[] = "daytime");
    void displayDress();
  };
Dress::Dress(char mtrl[], int sz, char stl[])
{
  strcpy(material,mtrl);
  strcoy(size,sz);
  strcpy(style,stl);
  price = 29.99;
  if(strcmp(material,"silk") == 0)
    price += 20.00;
  if(strcmp(style, "evening")==0)
    price += 40.00;
 }

void Dress::displayDress()
 {
   cout<<"A size "<<size<<" dress made of "<<material<<" and suitable for "<<
        style<<" wear costs $"<<price<<endl;
  }

void main()
  {
     cout<<"Dress sale! $29.99. Only $20 more for silk. Only $40 more for evening designs."<<endl;
      Dress dressA, dressB("wool"), dressC("silk",14,"evening"),
           dressD("denim",4,"casual"),dressE("silk",8,"business");
     dressA.displayDress();
     dressB.displayDress();
     dressC.displayDress();
     dressD.displayDress();
     dressE.displayDress();
     getch();
  }
0
Comment
Question by:KimHopper
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6937518
What specifically do you need debugged?

What's the problem?
0
 

Author Comment

by:KimHopper
ID: 6937531
When I compile the code, I have 4 errors which states "no overload function takes 3 parameters"  I am unsure what to do with that
0
 
LVL 86

Expert Comment

by:jkr
ID: 6937540
Axter, like http://www.experts-exchange.com/cplusprog/Q.20288159.html (huh, another Kim?), I guess this is homework - the coding styles are too similar, and the task may have been "what is wrong with this code, as because of " strcoy(size,sz);" (an 'int'!!) it won't even compile, not to speak of "debugging"...
0
 
LVL 3

Accepted Solution

by:
ruff_ryder earned 30 total points
ID: 6937552
The error:

no overload function takes 3 parameters

relates to your code in main() where you are attempting to call the Dress constructor with 3 arguments as against the 2 that it expects.

0
 

Expert Comment

by:KimZeerip
ID: 6937668
How do I fix this error?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 86

Expert Comment

by:jkr
ID: 6937679
From: KimHopper  Date: 04/12/2002 11:50AM PST  
When I compile the code, I have 4 errors which states "no overload function takes 3 parameters"  I am
unsure what to do with that  

From: KimZeerip  Date: 04/12/2002 12:55PM PST  
How do I fix this error?  


Ouch. Double accounts. I was hoping that I was wrong...
0
 
LVL 3

Expert Comment

by:ruff_ryder
ID: 6937969
Do a bit of reading on Classes and handling functions in C++ KimZeerip/KimHopper. This is basic knowledge you must have to proceed in this language.

Look at your code ... you have the following:

Dress(const char mtrl[] = "cotton",const char stl[] = "daytime");

// ....

Dress::Dress(char mtrl[], int sz, char stl[])
{
  ...
}

See the difference??
0
 

Expert Comment

by:KimZeerip
ID: 6938210
Are you saying that the
int sz
has to be in the following line as well?:

 Dress(const char mtrl[] = "cotton",const char stl[] = "daytime");
0
 
LVL 3

Expert Comment

by:ruff_ryder
ID: 6938991
yep yep.

Dress(const char mtrl[] = "cotton",const char stl[] = "daytime");

the above is your class declaration of the Dress COnstructor.


This code blow is your implementation of the Dress constructor. The signature of the Dress Constructor must be the same in the both the declaration and definition of the Constructor.

Dress::Dress(char mtrl[], int sz, char stl[])
{
 ...
}


As I said before though, do some reading.
0
 
LVL 11

Expert Comment

by:griessh
ID: 7012090
Dear KimHopper

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "ruff_ryder"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7027907
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now