Solved

Debug Help

Posted on 2002-04-12
11
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

740 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