From e76eeb661ad20bc57b9d148b96788b3ec1a4b2ee Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Thu, 5 Jan 2017 16:59:01 +0100 Subject: [PATCH] Initializing values can (and should) be done with this syntax --- word.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/word.cpp b/word.cpp index da10b7c1..61ba2f1f 100644 --- a/word.cpp +++ b/word.cpp @@ -1,22 +1,25 @@ #include "word.h" +// Image word Word::Word(LazyLoadedImage* image, Type type, const QString& copytext, const QString& tooltip) + : m_image(image) + , m_text() + , m_isImage(true) + , m_type(type) + , m_copyText(copytext) + , m_tooltip(tooltip) { - this->m_image = image; - m_isImage = true; - m_type = type; - m_copyText = copytext; - m_tooltip = tooltip; } +// Text word Word::Word(const QString& text, Type type, const QString& copytext, const QString& tooltip) + : m_image(nullptr) + , m_text(text) + , m_isImage(true) + , m_type(type) + , m_copyText(copytext) + , m_tooltip(tooltip) { - this->m_image = NULL; - this->m_text = text; - m_isImage = false; - m_type = type; - m_copyText = copytext; - m_tooltip = tooltip; } Word::~Word()