如何在c ++中修复所有字符串的“字符串”长度

时间:2017-05-13 11:22:07

标签: c++ string file

我在基类的几个地方使用了字符串。还有3个儿童班。我想修复所有字符串的大小,所以当我通过ios::binary模式在文件中写入对象时,所有记录的大小都相同,我可以轻松阅读和搜索。还是会保持尺寸相同?

class product
{
protected:
    int sku; //Stock keeping unit number
    float price; // price of product
    string name; // name of product
    int availibility; //number of Items available
    string brand; //name of brand otherwise artist name
public:
    product();
    product(int,float,string,int,string);
    ~product();
    void display();
    void set_sku(int);
    void set_price(float);
    void set_name(string);
    void set_availibilty(int);
    void set_brand(string);
    int get_sku();
    float get_price();
    string get_name();
    int get_availibility();
    string get_brand();
};

0 个答案:

没有答案