code:
//File:Str.h
#ifndef STR_H
#define STR_H
#include"string.h"
class Str
{
public:
Str();
void setId(int);
void setName(string);
void setPrice(int);
void setStock(int);
void Display()const;
int getId()const;
string getName()const;
int getPrice()const;
int getStock()const;
private:
int id;
string name;
int price;
int stock;
};
#endif
/--------------------------------------------------------------------/
//File:Str.cpp
#include"Str.h"
#include<iostream>
#include<string>
using namespace std;
Str::Str()
{
id = 0;
name = "empty";
price = 0;
stock = 0;
}
void Str::setId(int val)
{
id = val;
}
void Str::setName(string val)
{
name = val;
}
void Str::setPrice(int val)
{
price = val;
}
void Str::setStock(int val)
{
stock = val;
}
void Str:isplay()const
{
cout<<"ID = "<<id<<endl;
cout<<"Name = "<<name<<endl;
cout<<"Price = "<<price<<endl;
cout<<"Stock = "<<stock<<endl;
}
int Str::getId()const
{
return id;
}
string Str::getName()const
{
return name;
}
int Str::getPrice()const
{
return price;
}
int Str::getStock()const
{
return stock;
}
/--------------------------------------------------------------------/
Please help me.How to use string in this code?