<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Operatorenüberladung]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein Problem mit der Operatorenüberladung. Ich will für eine eigene String-Klasse den ==-Operator überladen.</p>
<p>Der VC++ Compiler akzeptiert folgendes:</p>
<pre><code>bool String::operator==(String&amp; s){
}
</code></pre>
<p>Der g++ akzeptiert das nicht: es sagt beim Aufruf des Operators, dass er ihn nicht finden kann. Deshalb habe ich folgendes probiert:</p>
<pre><code>bool String::operator==(const String&amp; s) const{
}
</code></pre>
<p>Dabei gibt es aber ein anderes Problem: Sobald ich innerhalb des Operators eine Memberfunktion des Parameters s aufrufen will (z.B. s.strLength()) tritt dieser Fehler auf:</p>
<p>error: passing <code>const String' as \</code>this' argument of `int String::getStringLength()'<br />
discards qualifiers</p>
<p>Wie wird der Operator ordnungsgemäß überladen?</p>
<p>Danke!</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/120282/operatorenüberladung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 07:32:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/120282.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Sep 2005 16:05:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 16:05:43 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein Problem mit der Operatorenüberladung. Ich will für eine eigene String-Klasse den ==-Operator überladen.</p>
<p>Der VC++ Compiler akzeptiert folgendes:</p>
<pre><code>bool String::operator==(String&amp; s){
}
</code></pre>
<p>Der g++ akzeptiert das nicht: es sagt beim Aufruf des Operators, dass er ihn nicht finden kann. Deshalb habe ich folgendes probiert:</p>
<pre><code>bool String::operator==(const String&amp; s) const{
}
</code></pre>
<p>Dabei gibt es aber ein anderes Problem: Sobald ich innerhalb des Operators eine Memberfunktion des Parameters s aufrufen will (z.B. s.strLength()) tritt dieser Fehler auf:</p>
<p>error: passing <code>const String' as \</code>this' argument of `int String::getStringLength()'<br />
discards qualifiers</p>
<p>Wie wird der Operator ordnungsgemäß überladen?</p>
<p>Danke!</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869690</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 16:05:43 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 16:10:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// In der Klasse:
friend bool operator== (const String&amp; lhs, const String&amp; rhs);

// Außerhalb:
bool operator == (const String&amp; lhs, const String&amp; rhs);
</code></pre>
<p>Abgesehen davon, dass man ihn als Non-Member erstellt, ist also die const-Version die einzig Richtige.</p>
<p>Der Fehler hier:</p>
<blockquote>
<p>error: passing <code>const String' as \</code>this' argument of `int String::getStringLength()'<br />
discards qualifiers</p>
</blockquote>
<p>beruht auf deiner Non-Const-Correctness.</p>
<p>Der operator== darf nichts an den Objekten selbst verändern (wieso sollte er auch) und darf daher nur Methoden der Klasse aufrufen die das nicht tun. Damit du strLength() aufrufen darfst (Anm: getLength() ist ein geeigneter Name) muss sie als const deklariert sein:</p>
<pre><code class="language-cpp">// In der Klasse:
size_t strLength () const;
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869693</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869693</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 16:10:44 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 16:51:52 GMT]]></title><description><![CDATA[<p>Danke, das hilft mir schon einmal. Jetzt habe ich aber mit dem Zuweisungsoperator = ein ähnliches Problem:</p>
<p>Die Definition lautet:</p>
<pre><code>String&amp; operator=(const String&amp; s){
}
</code></pre>
<p>Beim Aufruf schreibt der Compiler folgendes:</p>
<p>undefined reference to `String::operator=(HLPHelper::HLPStrings::String const&amp;) const'</p>
<p>Naja, die Fehlermeldung stimmt ja: es gibt keinen operator= mit const zum Schluss. Aber ein Zuweisungsoperator kann ja nicht const sein!? Sonst kann er ja nichts zuweisen...</p>
<p>Wie muss dieser Operator aussehen?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869720</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 16:51:52 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 16:53:38 GMT]]></title><description><![CDATA[<p>Dein Zuweisungs-Operator passt soweit, allerdings muss er im Gegensatz zum ==-Operator Member der Klasse sein! Eventuell beruht das Problem ja darauf?!</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869722</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 16:53:38 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 16:56:47 GMT]]></title><description><![CDATA[<p>Hier lad das mal, hab ich mal für meine Klasse geschrieben:</p>
<p><a href="http://cache.sidewindershome.net/Operators.h" rel="nofollow">http://cache.sidewindershome.net/Operators.h</a></p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869723</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 16:56:47 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:08:57 GMT]]></title><description><![CDATA[<p>Der Operator ist Member der Klasse.</p>
<p>Vielleicht stimmt ja mit der Verwendung des Operators etwas nicht. Die String-Klasse wird (unter anderem) für ein ebenfalls selbst geschriebenes assoziatives Array zur Identifikation verwendet. Die Methode zum Einfügen neuer Objekte in das Array stelle ich diese Methode zur Verfügung:</p>
<pre><code>void addObject(HLPStrings::String id, T object){...}
</code></pre>
<p>Genau bei dieser Zeile meckert er. Die String-Klasse stellt folgende Member zur Verfügung:</p>
<pre><code>String();
String(const String&amp; s);
String(const char* c);

String&amp; operator=(const String s);
String&amp; operator=(const String&amp; s);
String operator+(String&amp; s);
String&amp; operator+=(String&amp; s) ;
bool operator==(const String&amp; s2) const;
bool operator!=(const String&amp; s2) const;

~String();
</code></pre>
<p>Ich würde sagen beim Aufruf von addObject müsste der String über den Copy-Konstruktor kopiert und über den Stack and die add-Methode übergeben werden.</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869725</guid><dc:creator><![CDATA[ChisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:13:25 GMT]]></title><description><![CDATA[<p>Aja, die Fehlermeldung wollte ich auch noch posten:<br />
undefined reference to `HLPStrings::String::operator=(HLPStrings::String const&amp;) const'</p>
<p>Und die Vergleichoperatoren sind nach der letzten Änderung natürlich keine Klassenmember mehr.</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869727</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:13:25 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:13:30 GMT]]></title><description><![CDATA[<blockquote>
<p>String&amp; operator=(const String s);<br />
String&amp; operator=(const String&amp; s);</p>
</blockquote>
<p>Wieso gibts hier zwei?</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869728</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:13:30 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:20:37 GMT]]></title><description><![CDATA[<p>Es hat zuerst nur einen gegeben, aber weil es nicht funktioniert hat (gleicher Fehler) hab ich testweise den 2. hinzugefügt.</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869731</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:20:37 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:32:08 GMT]]></title><description><![CDATA[<p>Hmm, keine Ahnung...zeig mal die gesamte String-Klasse <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Stilistische Änderung:</p>
<pre><code class="language-cpp">void addObject(HLPStrings::String id, T object){...}
// geändert zu:
void addObject(const HLPStrings::String&amp; id, T object){...}
</code></pre>
<p>Verhindert, dass der String jedesmal kopiert werden muss wenn du ihn übergibst. Hilft beim konkreten Problem aber auch nix.</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869736</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:32:08 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:39:13 GMT]]></title><description><![CDATA[<p>Ok, hier die gesamte String-Klasse. Sie befindet sich im Namespace HLPHelper und ist eine innere Klasse von HLPStrings.</p>
<pre><code>#include &lt;HLPStrings.h&gt;	// EH

using namespace HLPHelper;

// ========== class HLPStrings ==========

// Returns the length of a native C string
int32 HLPStrings::strLen(const char8* c){
	int32 i = 0;
	while (c[++i] != '\0');
	return i;
}

// ========== class HLPStrings::String ==========

// Compares this string with another one
bool HLPStrings::String::operator==(const String&amp; s2) const{
	int32 strLen1 = HLPHelper::HLPStrings::strLen(this-&gt;getCString());
	int32 strLen2 = HLPHelper::HLPStrings::strLen(s2.getCString());

	// 2 strings with different lengths cannot be equal
	if (strLen1 != strLen2) return false;

	// Are all characters equal?
	for (int32 i = 0; i &lt; strLen1; i++)
		if ((this-&gt;getCString())[i] != (s2.getCString())[i]) return false;

	// The strings are equal
	return true;
}

// Compares this string with another one
bool HLPStrings::String::operator!=(const String&amp; s2) const{
	int32 strLen1 = HLPHelper::HLPStrings::strLen(this-&gt;getCString());
	int32 strLen2 = HLPHelper::HLPStrings::strLen(s2.getCString());

	// 2 strings with different lengths cannot be equal
	if (strLen1 != strLen2) return true;

	// Are all characters equal?
	for (int32 i = 0; i &lt; strLen1; i++)
		if ((this-&gt;getCString())[i] != (s2.getCString())[i]) return true;

	// The strings are equal
	return false;
}

// Compares this string with another one
bool operator==(const HLPHelper::HLPStrings::String&amp; s1, const HLPHelper::HLPStrings::String&amp; s2){
	int32 strLen1 = HLPHelper::HLPStrings::strLen(s1.getCString());
	int32 strLen2 = HLPHelper::HLPStrings::strLen(s2.getCString());

	// 2 strings with different lengths cannot be equal
	if (strLen1 != strLen2) return false;

	// Are all characters equal?
	for (int32 i = 0; i &lt; strLen1; i++)
		if ((s1.getCString())[i] != (s2.getCString())[i]) return false;

	// The strings are equal
	return true;
}

// Compares this string with another one
bool operator!=(const HLPHelper::HLPStrings::String&amp; s1, const HLPHelper::HLPStrings::String&amp; s2){
	int32 strLen1 = HLPHelper::HLPStrings::strLen(s1.getCString());
	int32 strLen2 = HLPHelper::HLPStrings::strLen(s2.getCString());

	// 2 strings with different lengths cannot be equal
	if (strLen1 != strLen2) return true;

	// Are all characters equal?
	for (int32 i = 0; i &lt; strLen1; i++)
		if ((s1.getCString())[i] != (s2.getCString())[i]) return true;

	// The strings are equal
	return false;
}

// Constructor for the string class (copy constructor)
HLPStrings::String::String(const String&amp; s){
	strLen = 0;
	chars = 0;
	if (s.getCString() != 0)
		setString(s.getCString());
}

// Constructor for the string class
HLPStrings::String::String(){
	strLen = 0;
	chars = 0;
}

// Constructor for the string class
HLPStrings::String::String(const char8* c){
	strLen = -1;
	// Determine string length
	while (true)
		if (c[++strLen] == '\0') break;
	// Copy string
	chars = new char8[strLen + 1];
	for (int32 i = 0; i &lt; strLen; i++)
		chars[i] = c[i];
	chars[strLen] = '\0';
}

// Destructor: Removes the string from memory
HLPStrings::String::~String(){
	if (chars != 0)
		delete []chars;
	strLen = 0;
}

// Copies the string
/*
HLPStrings::String&amp; HLPStrings::String::operator=(const String s){
	if (s.getCString() != 0)
		setString(s.getCString());
	else
		setString(&quot;&quot;);

	return *this;
}
*/

// Copies the string
HLPStrings::String&amp; HLPStrings::String::operator=(const String&amp; s){
	if (s.getCString() != 0)
		setString(s.getCString());
	else
		setString(&quot;&quot;);

	return *this;
}

HLPStrings::String HLPStrings::String::operator+(String&amp; s) {
	// Create a new string
	String newStr(this-&gt;getCString());
	newStr.append(&amp;s);	// Append the second string
	return newStr;		// Return the new string
}

// Does the same as append does
HLPStrings::String&amp; HLPStrings::String::operator+=( String&amp; s) {
	append(&amp;s);
	return *this;
}

// Compares this string with another one
bool HLPStrings::String::equals(String&amp; s){
	int32 strLen1 = this-&gt;getStrLen();
	int32 strLen2 = s.getStrLen();

	// 2 strings with different lengths can not be equal
	if (strLen1 != strLen2) return false;

	// Are all characters equal?
	for (int32 i = 0; i &lt; strLen1; i++)
		if ((this-&gt;getCString())[i] != (s.getCString())[i]) return false;

	// The strings are equal
	return true;
}

// Sets another string into this one
void HLPStrings::String::setString(String* s){
	setString(s-&gt;getCString());
}

// Sets a C-string into this one
void HLPStrings::String::setString(const char8* c){
	// Delete old string (if necessary)
	if (chars != 0)
		delete []chars;
	strLen = 0;
	// Determine string length
	if (c != 0){
		while (true)
			if (c[++strLen] == '\0') break;
	}else{
		strLen = 0;
	}
	chars = new char8[strLen + 1];
	for (int32 i = 0; i &lt; strLen; i++)
		chars[i] = c[i];
	chars[strLen] = '\0';
}

// Appends a string to the current one
void HLPStrings::String::append(String* c){
	append(c-&gt;getCString());
}

// Appends a character to the current string
void HLPStrings::String::append(const char8 c){
	char8 tmpStr[2];
	tmpStr[0] = c;
	tmpStr[1] = '\0';
	append(tmpStr);
}

// Appends one C-string to the current string
void HLPStrings::String::append(const char8* c){
	int32 newStrLen = -1;
	// Determine string length
	while (true)
		if (c[++newStrLen] == '\0') break;

	// Create one new total string
	char8* totalString = new char8[strLen + newStrLen + 1];
	for (int32 i = 0; i &lt; strLen; i++)		// Copy old part of the string into the new char8 array
		totalString[i] = chars[i];
	for (int32 i = 0; i &lt; newStrLen; i++)		// Copy new part of the string into the new char8 array
		totalString[strLen + i] = c[i];
	strLen += newStrLen;
	totalString[strLen] = '\0';

	// Now, delete the old string and set the new one
	delete []chars;
	chars = totalString;
}

// Returns the length of the string
int32 HLPStrings::String::getStrLen(){
	return strLen;
}

// Returns the native C string
const char8* HLPStrings::String::getCString() const{
	return chars;
}

// Returns one character of the string
char8 HLPStrings::String::getChar(int32 index){
	if (index &gt;= strLen)
		return ' ';				// Out of bounds
	else
		return chars[index];
}

// Trims the current string
// (Note: This function does not only remove blanks at the beginning and at the end but all blanks in
//  the string)
void HLPStrings::String::trim(){
	HLPStrings::String s;
	for (int32 i = 0; i &lt; strLen; i++)
		if (chars[i] != ' ') s.append(chars[i]);
	setString(&amp;s);
}

// This function replaces one char8 with another
void HLPStrings::String::replace(char8 oldC, char8 newC){
	for (int32 i = 0; i &lt; strLen; i++)
		if (chars[i] == oldC) chars[i] = newC;
}

// Returns if the current string can be converted into a double64 value
// (Note: The convertion does never cause an error, but the result is not always useful).
bool HLPStrings::String::isDouble(){
	bool commaOccured = false;
	for (int32 i = 0; i &lt; strLen; i++){
		switch(chars[i]){
			case '+':
			case '-':
				// Only allowed at the beginning of the string
                if (i &gt; 0)
					return false;
				break;
			case '.':
			case ',':
				// Only one such sign is allowed in a string
				if (commaOccured == true)
					return false;
				commaOccured = true;
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				break;
			default:
				// Other chars are not allowed
				return false;
				break;
		}
	}

	return true;
}

// Converts the current string into a long64 number and returns it
long64 HLPStrings::String::getLong(){
	int32 sign = 1;		// 1 = +; -1 = -
	long64 result = 0;
	long64 digitValue;	// A temporary storage for the real value of one digit
	for (int32 i = 0; i &lt; strLen; i++){
		switch(chars[i]){
			case '+':
				// Store sign
				sign = 1;
				break;
			case '-':
				// Store sign
				sign = -1;
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				digitValue = (chars[i] - '0');
				result *= 10;
				result += digitValue;
				break;
			default:
				break;
		}
	}
	// Process sign
	result *= sign;

	return result;
}

// Converts the current string into a double64 number and returns it
double64 HLPStrings::String::getDouble(){
	int32 sign = 1;		// 1 = +; -1 = -
	bool comma = false;	// Process the digits after the comma (true) or before the comma (false)?
	int32 commaCount = 0;
	double64 result = 0.0;
	double64 digitValue;	// A temporary storage for the real value of one digit
	for (int32 i = 0; i &lt; strLen; i++){
		if (comma == true)
			commaCount++;
		switch(chars[i]){
			case '+':
				// Store sign
				sign = 1;
				break;
			case '-':
				// Store sign
				sign = -1;
				break;
			case '.':
			case ',':
				// Start counting the digits after the comma
				comma = true;
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				// Process digit
				if (comma == false){				// Before the comma
					digitValue = (chars[i] - '0');
					result *= 10;
					result += digitValue;
				}else{								// After the comma
					digitValue = (chars[i] - '0');
					// Now, divide the number by 10 as often as we have digits after the comma.
					for (int32 i = 0; i &lt; commaCount; i++)
						digitValue /= 10;
					result += digitValue;
				}

				break;
			default:
				break;
		}
	}
	// Process sign
	result *= sign;

	return result;
}

// Converts the current string into a float32 number and returns it
float32 HLPStrings::String::getFloat(){
	int32 sign = 1;		// 1 = +; -1 = -
	bool comma = false;	// Process the digits after the comma (true) or before the comma (false)?
	int32 commaCount = 0;
	float32 result = 0.0;
	float32 digitValue;	// A temporary storage for the real value of one digit
	for (int32 i = 0; i &lt; strLen; i++){
		if (comma == true)
			commaCount++;
		switch(chars[i]){
			case '+':
				// Store sign
				sign = 1;
				break;
			case '-':
				// Store sign
				sign = -1;
				break;
			case '.':
			case ',':
				// Start counting the digits after the comma
				comma = true;
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				// Process digit
				if (comma == false){				// Before the comma
					digitValue = (float32)(int32)(chars[i] - '0');
					result *= 10;
					result += digitValue;
				}else{								// After the comma
					digitValue = (float32)(int32)(chars[i] - '0');
					// Now, divide the number by 10 as often as we have digits after the comma.
					for (int32 i = 0; i &lt; commaCount; i++)
						digitValue /= 10;
					result += digitValue;
				}

				break;
			default:
				break;
		}
	}
	// Process sign
	result *= sign;

	return result;
}

// Converts a double64 value into a string and sets this string
void HLPStrings::String::setDouble(double64 d){
	// Create a character array which is long64 enough in all cases
	char8 tmpStringBuffer[30];	// A maximum of 30 digits is supported
	int32 charIndex = 0;			// Points to the character which is written now
	// First of all, write the sign into the string
	if (d &lt; 0){
		tmpStringBuffer[charIndex++] = '-';
		d = -d;	// Remove the sign from the double64 value
	}

	// Extract two different long64 values: before and after the comma
	long64 bComma = (long64)d;
	double64 tmpD = (d - (double64)bComma);
	for (int32 i = 0; i &lt; 8; i++)	// Convert a maximum of 8 digits after the comma
		tmpD *= 10;
	long64 aComma = (long64)tmpD;
	int32 oldCharIndex;
	int32 tmp;

	// Now, convert the part before the comma
	oldCharIndex = charIndex;
	while (bComma &gt; 0){
		tmpStringBuffer[charIndex++] = '0' + (uchar8)(bComma % 10);
		bComma /= 10;
	}
	// Reverse the string from oldCharIndex until charIndex
	for (int32 i = 0; i &lt; (charIndex - oldCharIndex) / 2; i++){
		tmp = tmpStringBuffer[charIndex - 1 - i];
		tmpStringBuffer[charIndex - 1 - i] = tmpStringBuffer[oldCharIndex + i];
		tmpStringBuffer[oldCharIndex + i] = tmp;
	}

	// Check if the number has digits after the comma
	if (aComma &gt; 0){
		// Add the comma
		tmpStringBuffer[charIndex++] = '.';

		// Now, convert the part before the comma
		oldCharIndex = charIndex;
		while (aComma &gt; 0){
			tmpStringBuffer[charIndex++] = '0' + (uchar8)(aComma % 10);
			aComma /= 10;
		}
		// Reverse the string from oldCharIndex until charIndex
		for (int32 i = 0; i &lt; (charIndex - oldCharIndex) / 2; i++){
			tmp = tmpStringBuffer[charIndex - 1 - i];
			tmpStringBuffer[charIndex - 1 - i] = tmpStringBuffer[oldCharIndex + i];
			tmpStringBuffer[oldCharIndex + i] = tmp;
		}
		tmpStringBuffer[charIndex] = '\0';
		// Check if we can move the \0 to the beginning of the string. This is possible if the last
		// digit (after the comma) is 0
		while (tmpStringBuffer[charIndex - 1] == '0'){
			charIndex--;
			tmpStringBuffer[charIndex] = '\0';
		}
	}else{
		tmpStringBuffer[charIndex] = '\0';
	}

	// Now, use the generated string
	setString(tmpStringBuffer);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/869740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869740</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:39:13 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:44:25 GMT]]></title><description><![CDATA[<p>Ich meinte die Header-Datei <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>BTW: Die aktuelle bitte, hier sind ja die OPs noch Member, etc. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869742</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:44:25 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 17:50:52 GMT]]></title><description><![CDATA[<p>Achso, den header <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
<pre><code>namespace HLPHelper{

	class HLPStrings{
	private:

	public:
		static int32 strLen(const char8* c);

		// String control class
		class String{
		private:
			char8* chars;
			int32 strLen;
		public:
			String();
			String(const String&amp; s);
			String(const char8* c);
			void append(String* c);
			void append(const char8* c);
			void append(const char8 c);
			void setString(String* s);
			void setString(const char8* c);
			HLPStrings::String&amp; operator=(const String s);
			HLPStrings::String&amp; operator=(const String&amp; s);
			HLPStrings::String operator+(String&amp; s);
			HLPStrings::String&amp; operator+=(String&amp; s) ;
			friend bool operator==(const String&amp; s1, const String&amp; s2);
			friend bool operator!=(const String&amp; s1, const String&amp; s2);
			bool String::equals(String&amp; s);
			const char8* getCString() const;
			int32 getStrLen();
			char8 getChar(int32 index);
			void trim();
			bool isDouble();
			long64 getLong();
			double64 getDouble();
			float32 getFloat();
			void setDouble(double64 d);
			void replace(char8 oldC, char8 newC);

			~String();
		};

	};

}

bool operator==(const HLPHelper::HLPStrings::String&amp; s1, const HLPHelper::HLPStrings::String&amp; s2);
bool operator!=(const HLPHelper::HLPStrings::String&amp; s1, const HLPHelper::HLPStrings::String&amp; s2);
</code></pre>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869746</guid><dc:creator><![CDATA[ChrisR]]></dc:creator><pubDate>Sun, 11 Sep 2005 17:50:52 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 19:26:35 GMT]]></title><description><![CDATA[<p>ChrisR schrieb:</p>
<blockquote>
<p>Aja, die Fehlermeldung wollte ich auch noch posten:<br />
undefined reference to `HLPStrings::String::operator=(HLPStrings::String const&amp;) const'</p>
</blockquote>
<p>Du rufst op= für ein konstantes Objekt auf, was nicht funktionieren kann. Zeig mal die Zeile, in der der Fehler auftritt.</p>
<p>btw:<br />
Du hast enorme Probleme mit const-correctness. Schnapp dir ein gutes Tutorial, in dem erklärt wird, wann Methoden bzw. Operatoren const gemacht werden und arbeite daran.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869811</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 11 Sep 2005 19:26:35 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Sun, 11 Sep 2005 19:54:50 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/2813">@groovemaster</a>: Die wurde doch schon gepostet, siehe weiter oben die Funktion. Deswegen kann dein Schluss auch nciht richtig sein. Hab ich mir auch schon gedacht.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/20453">@ChrisR</a>: Ganz allgemein ist die Klasse nicht das Optimum, die wichtigsten Probleme:<br />
void append(String* c); &lt;- so nicht<br />
void setString(String* s); &lt;- so nicht<br />
HLPStrings::String&amp; operator=(const String s); &lt;- den hier weg endlich<br />
bool String::equals(String&amp; s); &lt;- hier const String&amp;</p>
<p>Ansonsten kann ich aber nicht den Grund des Problems erkennen. Kanns sein, dass dein Compiler zwar auf die Funktion zeigt, das Problem aber nicht im Kopf stattfindet sondern irgendwo im Rumpf dieser Funktion? Was macht denn diese addObject?</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/869832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/869832</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 11 Sep 2005 19:54:50 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Mon, 12 Sep 2005 11:17:59 GMT]]></title><description><![CDATA[<p>SideWinder schrieb:</p>
<blockquote>
<p>Die wurde doch schon gepostet</p>
</blockquote>
<p>Was? Die Fehlerstelle? Zeig mal wo, bin gerade zu faul, erst den ganzen Code durchzuschaun. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/870140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/870140</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Mon, 12 Sep 2005 11:17:59 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Mon, 12 Sep 2005 11:19:36 GMT]]></title><description><![CDATA[<p>omg, bist du faul <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>ChisR schrieb:</p>
<blockquote>
<pre><code>void addObject(HLPStrings::String id, T object){...}
</code></pre>
<p>Genau bei dieser Zeile meckert er.</p>
</blockquote>
<p>Vielleicht erkennst du ja den Fehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":-/"
      alt="😕"
    /></p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/870141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/870141</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Mon, 12 Sep 2005 11:19:36 GMT</pubDate></item><item><title><![CDATA[Reply to Operatorenüberladung on Mon, 12 Sep 2005 11:43:12 GMT]]></title><description><![CDATA[<p>SideWinder schrieb:</p>
<blockquote>
<p>omg, bist du faul <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Sind das nicht alle Programmierer? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>ChisR schrieb:</p>
<blockquote>
<pre><code>void addObject(HLPStrings::String id, T object){...}
</code></pre>
<p>Genau bei dieser Zeile meckert er.</p>
</blockquote>
<p>So wird das nix. Man braucht schon den Aufruf bzw. die Definition von addObject, um den Fehler zu finden. Momentan kann ich hier jedenfalls keine Verwendung von op= erkennen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/870165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/870165</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Mon, 12 Sep 2005 11:43:12 GMT</pubDate></item></channel></rss>