什么是java.io.Serializable的C/C++等价?什么是java.io.Serializable的C/C++等价?
有很系列化库的引用:
而且有:
- http://troydhanson.github.io/tpl/index.html
- http://www.boost.org/doc/libs/1_41_0/libs/serialization/doc/index.html
- https://developers.google.com/protocol-buffers/docs/cpptutorial#optimization-tips
但是确实存在这样的等价关系吗?
因此,如果我在Java中有如下的抽象类,那么C/C++中的可序列化类将如何看起来像?
import java.io.Serializable;
public interface SuperMan extends Serializable{
/**
* Count the number of abilities.
* @return
*/
public int countAbility();
/**
* Get the ability with index k.
* @param k
* @return
*/
public long getAbility(int k);
/**
* Get the array of ability from his hand.
* @param k
* @return
*/
public int[] getAbilityFromHand(int k);
/**
* Get the finger of the hand.
* @param k
* @return
*/
public int[][] getAbilityFromFinger(int k);
//check whether the finger with index k is removed.
public boolean hasFingerRemoved(int k);
/**
* Remove the finger with index k.
* @param k
*/
public void removeFinger(int k);
}
可以在任何序列化的C/C++对象只是继承像Java中?
C++标准库没有任何标准库。其他库(如我知道的MFC)可能支持序列化。虽然有XML,JSON等序列化库。 – Ajay
这不是你所要求的,而是根据通常在C++中完成的事情(通常证明相当可行),[boost](http://www.boost.org/doc/libs/1_61_0/libs/)序列化/ doc /)值得一看。 –
我不会寻找基本上是语言级别的Java特性的C++等价物,而是专注于如何处理C++中的序列化。标准的方法可能是相似的,但不一定必须 - 毕竟,C++和Java有不同的内存模型等等。 – Thomas