Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'example/serialize/serialize.cpp')
-rw-r--r--example/serialize/serialize.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/example/serialize/serialize.cpp b/example/serialize/serialize.cpp
index b1192ba5..160730d5 100644
--- a/example/serialize/serialize.cpp
+++ b/example/serialize/serialize.cpp
@@ -12,7 +12,7 @@ using namespace rapidjson;
class Person {
public:
Person(const std::string& name, unsigned age) : name_(name), age_(age) {}
- virtual ~Person() {}
+ virtual ~Person();
protected:
template <typename Writer>
@@ -30,6 +30,9 @@ private:
unsigned age_;
};
+Person::~Person() {
+}
+
class Education {
public:
Education(const std::string& school, double GPA) : school_(school), GPA_(GPA) {}
@@ -56,7 +59,7 @@ class Dependent : public Person {
public:
Dependent(const std::string& name, unsigned age, Education* education = 0) : Person(name, age), education_(education) {}
Dependent(const Dependent& rhs) : Person(rhs) { education_ = (rhs.education_ == 0) ? 0 : new Education(*rhs.education_); }
- ~Dependent() { delete education_; }
+ virtual ~Dependent();
template <typename Writer>
void Serialize(Writer& writer) const {
@@ -77,9 +80,14 @@ private:
Education *education_;
};
+Dependent::~Dependent() {
+ delete education_;
+}
+
class Employee : public Person {
public:
Employee(const std::string& name, unsigned age, bool married) : Person(name, age), married_(married) {}
+ virtual ~Employee();
void AddDependent(const Dependent& dependent) {
dependents_.push_back(dependent);
@@ -104,10 +112,13 @@ public:
}
private:
- bool married_;
std::vector<Dependent> dependents_;
+ bool married_;
};
+Employee::~Employee() {
+}
+
int main(int, char*[]) {
std::vector<Employee> employees;