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
Solved

Debug Help

Posted on 2002-04-12
11
357 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
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.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Unable to start eclipse ? 17 153
Least Squares Curve Fitting 4 96
operator overload: incompatible type and too many params 5 83
I could not set window to top 4 20
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 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