aboutsummaryrefslogtreecommitdiffstats
path: root/examples/samplebinding/icecream.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-17 14:16:33 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-21 16:15:35 +0100
commitc3c692d26e2d6976afa226a3f49e1745e94712e7 (patch)
tree2ecb64587c5a2250b9c3f6f95cff1f068c2e0970 /examples/samplebinding/icecream.cpp
parentec7ad296f48f3f1856c3eb7cc3685249a096d6b8 (diff)
Polish the samplebinding example
- Use a std::shared_ptr for internal storage. - Simplify copy and assignment. - Fix constness of the flavor accessor - Add ostream operator to IceCream Pick-to: 6.2 Change-Id: I814fa14095cbb96ab5642735e16b8b50101d4771 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/samplebinding/icecream.cpp')
-rw-r--r--examples/samplebinding/icecream.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/examples/samplebinding/icecream.cpp b/examples/samplebinding/icecream.cpp
index 8d40302da..9a65e396f 100644
--- a/examples/samplebinding/icecream.cpp
+++ b/examples/samplebinding/icecream.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt for Python examples of the Qt Toolkit.
@@ -50,11 +50,13 @@
#include "icecream.h"
+#include <iostream>
+
Icecream::Icecream(const std::string &flavor) : m_flavor(flavor) {}
-Icecream::~Icecream() {}
+Icecream::~Icecream() = default;
-const std::string Icecream::getFlavor()
+std::string Icecream::getFlavor() const
{
return m_flavor;
}
@@ -63,3 +65,9 @@ Icecream *Icecream::clone()
{
return new Icecream(*this);
}
+
+std::ostream &operator<<(std::ostream &str, const Icecream &i)
+{
+ str << i.getFlavor();
+ return str;
+}