Solved

Debug Help

Posted on 2002-04-12
11
356 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
MSVCR80.dll crash 2 140
Connecting to MS SQL db from Win32 application written in C 3 86
Android development question 2 38
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

831 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