Error on Dress class header and cpp files

I'm doing a Dress class by using header and cpp files. When I develop the codes for both my header(given) and cpp files and wanted to compile them, I have an error on my cpp file, line 6,"Dress::Dress(string m, string st, int sz, double p". The second mentioned "Dress" is underlined in red which is undertstood to have an error in C++. May I know why is it underlined?

This is my header file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#pragma once
#include <iostream>
#include <string>
using namespace std;

class Dress
{
	private:
		string material;
		int size;
		string style;
		double price;
	public:
		Dress(string = "", int = 0, string = "", double = 0.0);
		void displayDress();
		double getPrice();
};


This is my cpp file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include "dress.h"
using namespace std;

Dress::Dress(string m, string st, int sz, double p)
{
	material = m;
	style = st;
	size = sz;
	price = p;
};

double Dress::getPrice() 
{ 
	if (material == "silk")
	{
		price = price + 20;
	}
	if (style == "evening")
	{
		price = price + 40;
	}
	return price;
}

void Dress::displayDress()
{
	cout << "Material: " << material << endl;
	cout << "Style: " << style << endl;
	cout << "Size: " << size << endl;
	cout << "Price: " << price << endl;
}
the order is switched.
you are expecting a string , int ,string ,double
you wrote string, string int, double.


Dress(string = "", int = 0, string = "", double = 0.0)

Dress(string m, string st, int sz, double p
)
Topic archived. No new replies allowed.