如何在c ++中序列化对象的向量? [英] How do I serialize the vector of an object in c++?
本文介绍了如何在c ++中序列化对象的向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有以下课程
suppose I have the following class
#ifndef TRAY_H
#define TRAY_H
#include "EGG.h";
#include "FLOUR.h";
class TRAY
{
double price;
std::vector<EGG> eggs;
public:
TRAY(int number);
~TRAY();
double getTotalPrice();
std::vector<EGG> getEggs();
};
#endif
我怎么样?如何使用sqlite3来序列化一个TRAY对象的egg c ++?
另外一个问题是如果 可以序列化一个对象没有属性,即它只有功能。
有用的资源: SQLite C / C ++教程
How would I go about serializing a TRAY object's eggs inc c++ using sqlite3?
One other question I have is if it is possible to serialize an object that has no attributes, i.e. it has only functions.
Useful resources: SQLite C/C++ Tutorial
推荐答案
您可以编写自己的代码来序列化向量
(反过来序列化vector
的所有项目)或使用,例如, boost::serialization [ ^ ]。
You may either write your own code for serializing avector
(which in turn serializes all the items of thevector
) or use, for instance, boost::serialization[^].
这篇关于如何在c ++中序列化对象的向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文