Тема: Допоможіть знайти помилку.
ПОМИЛКА:
This declaration has no storage class or type specifier.
Ось код.
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class Device{
private:
string Name, Maker;
int Warranty,Price;
public:
Device() : Name(" "), Maker(" "), Warranty(0), Price(0){}
void set(string nm, string mk, int wr, int rp){
Name = nm;
Maker = mk;
Warranty = wr;
Price = rp;
}
void INPUT(istream &in){
in >> Name >> Maker >> Warranty >> Price;
}
void OUTPUT(ostream &out){
out << Name << " " << Maker << " " << Warranty << " " << Price;
}
string getName(){
return Name;
}
string getMaker(){
return Maker;
}
int getWarranty(){
return Warranty;
}
int getPrice(){
return Price;
}
};
void SORTING(Device *a, int n){
Device temp;
for (int i = 0; i < n; i++)
for (int j = 0; j<n - 1 - i; j++)
if (a[j].getPrice()>a[j + 1].getPrice())
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
void PRINTING(Device *a, int n, int warr){
for (int i = 0; i < n; i++){
if (a[i].getWarranty()> warr )
a[i].OUTPUT(cout);
}
}
void main(){
int n, warr;
ifstream input("Device.txt");
ofstream output("sorted.txt");
input >> n;
Device *a = new Device[n];
for (int i = 0; i < n; i++){
a[i].INPUT(input);
}
SORTING(a, n);
for (int i = 0; i < n; i++){
a[i].OUTPUT(output);
}
cout << "Enter the minimum warranty:" << endl;
cin >> warr;
PRINTING(a, n, warr);
delete []a;
input.close();
output.close();
system("pause");
}