0

Ok im debugging this program for school and I have 3/4 parts done but im stuck on this part.

class Outfit
{
private:
      Dress dress;
      Shoes shoes;
      double price;
   public:
      static const double DISCOUNT;
      Outfit(string, int, string, string, int, string);
      void displayOutfit();
};
const double Outfit::DISCOUNT = 0.20;

Outfit::Outfit(string m1, int sz1, string style1, string m2, int sz2, string style2)
 dress(m1, sz1, style1), shoes(m2, sz2, style2);

  price = dress.getPrice() + shoes.getPrice();
price = price - (price * DISCOUNT);

void Outfit::displayOutfit()
{
   dress.displayDress();
   shoes.displayShoes();
   cout << "With " << (DISCOUNT * 100) << "% discount, outfit is " << 
     price << endl;
}

Im getting these errors 
1>------ Build started: Project: Debug8, Configuration: Debug Win32 ------
1>  debugg8.cpp
1>..\..\debugg8.cpp(178): error C3646: 'dress' : unknown override specifier
1>..\..\debugg8.cpp(178): error C2065: 'm1' : undeclared identifier
1>..\..\debugg8.cpp(178): error C2065: 'sz1' : undeclared identifier
1>..\..\debugg8.cpp(178): error C2065: 'style1' : undeclared identifier
1>..\..\debugg8.cpp(178): error C2761: '{ctor}' : member function redeclaration not allowed
1>..\..\debugg8.cpp(178): error C2065: 'm2' : undeclared identifier
1>..\..\debugg8.cpp(178): error C2065: 'sz2' : undeclared identifier
1>..\..\debugg8.cpp(178): error C2065: 'style2' : undeclared identifier
1>..\..\debugg8.cpp(178): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\..\debugg8.cpp(178): error C2078: too many initializers
1>..\..\debugg8.cpp(180): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\..\debugg8.cpp(180): error C2065: 'dress' : undeclared identifier
1>..\..\debugg8.cpp(180): error C2228: left of '.getPrice' must have class/struct/union
1>          type is ''unknown-type''
1>..\..\debugg8.cpp(180): error C2039: 'getPrice' : is not a member of 'System::Int32'
1>          c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::Int32'
1>..\..\debugg8.cpp(181): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\..\debugg8.cpp(181): error C2374: 'price' : redefinition; multiple initialization
1>          ..\..\debugg8.cpp(180) : see declaration of 'price'
1>..\..\debugg8.cpp(181): error C2065: 'DISCOUNT' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


 Sorry This is my first time posting and Im not sure if there is a certain way to post these files
 If I comment out this part it works so im assuming it something here but I really dont understand what they are trying to do here. 
 Outfit::Outfit(string m1, int sz1, string style1, string m2, int sz2, string style2)
 dress(m1, sz1, style1), shoes(m2, sz2, style2);

  price = dress.getPrice() + shoes.getPrice();
price = price - (price * DISCOUNT);

Edited by Dani: Formatting

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by dark_sider_1
0

It's pretty difficult to read all of this code with the format you're using, but I'd at least suggest taking another look at line 15. Are there supposed to be curly brackets for the method, i.e. before that and after line 18? And maybe look at how to initialize dress and shoes in C++, similar to Java's Dress d = new Dress(m1...)

Edited by dark_sider_1: more specific

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.