<?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[syntax error : identifier &#x27;string&#x27;]]></title><description><![CDATA[<p>ahoi alle beisammen<br />
also ich wollte mir eine conainerklasse bastel für string. hab versucht alles schön zu machen. danke das design is halt standart<br />
leider bekomme ich beim kompilieren fehler bzgl string. denke er meint damit er kennt den indentifier 'string' nicht. ich habe jedoch string included.</p>
<p>Header:</p>
<pre><code class="language-cpp">#ifndef STRINGLIST_H
#define STRINGLIST_H

#include &lt;string&gt;

class StringList
{
public:
	StringList(void);
	StringList(const StringList&amp;);
	~StringList(void);

	void AddLine(string); //&lt;&lt;== Hier meckert der Kompiler
	void DelLine(int);

	int Length(void);

	string&amp; operator[](int);
	string&amp; operator=(const StringList&amp;);

private:
	string *list;
	int length;
};

#endif
</code></pre>
<p>Implementation:</p>
<pre><code class="language-cpp">#include &lt;cassert&gt;

#include &quot;StringList.h&quot;

StringList::StringList()
{
	list = NULL;
	length = 0;
}

StringList::StringList(cons StringList)
{

StringList::~StringList()
{
	if (list)
		delete []list;
}

void StringList::AddLine(string newline)
{
	string *temp = list;
	list = new string[length+1];

	for (int i = 0; i &lt; list.length; i++)
		list[i] = temp[i];

	list[length] = newline;

	length = length+1;
	delete []temp;
}

void StringList::DelLine(int line)
{
	assert(index &gt;= 0 &amp;&amp; index &lt; length);

	string *temp = list, *tmp = list;
	list = new string[length-1];
	int j = 0;

	for (int i = 0; i &lt; length-1; i++)
	{
		if (i == line)
			j++;
		else
		list[i] = tmp[j++];
	}

	length = length-1;
	delete temp;
}

int StringList::Length(void)
{
	return length;
}

string&amp; StringList::operator [](int index)
{
	assert(index &gt;= 0 &amp;&amp; index &lt; length);
	return list[index];
}

string&amp; StringList::operator =(const StringList&amp; source)
{
	if (this != &amp;source)
	{
		delete list;
		length = source.Length();
		list = new string[length];
		for (int i = 0; i &lt; length; i++)
			list[i] = source[i];
	}
	return *this;
}
</code></pre>
<p>Fehler:</p>
<pre><code>--------------------Configuration: test - Win32 Debug--------------------
Compiling...
main.cpp
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(13) : error C2061: syntax error : identifier 'string'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2143: syntax error : missing ';' before '&amp;'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2501: '[]' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2143: syntax error : missing ';' before '&amp;'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2501: '=' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2143: syntax error : missing ';' before '*'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2501: 'list' : missing storage-class or type specifiers
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(158) : error C2660: 'AddLine' : function does not take 1 parameters
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(166) : error C2660: 'AddLine' : function does not take 1 parameters
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(170) : error C2248: 'length' : cannot access private member declared in class 'StringList'
        c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(23) : see declaration of 'length'
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(172) : error C2664: 'DelPreWhitespace' : cannot convert parameter 1 from 'int' to 'class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

test.exe - 14 error(s), 0 warning(s)
</code></pre>
<p>es geht mir prinzipel erstmal nur um den ersten fehler, da ich denke, dass das problem, das dahinter steckt, das grundproblem ist.<br />
danke jetzt schon mal.</p>
<p>MamboKurt</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/130175/syntax-error-identifier-string</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 11:47:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/130175.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Dec 2005 15:25:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 15:25:54 GMT]]></title><description><![CDATA[<p>ahoi alle beisammen<br />
also ich wollte mir eine conainerklasse bastel für string. hab versucht alles schön zu machen. danke das design is halt standart<br />
leider bekomme ich beim kompilieren fehler bzgl string. denke er meint damit er kennt den indentifier 'string' nicht. ich habe jedoch string included.</p>
<p>Header:</p>
<pre><code class="language-cpp">#ifndef STRINGLIST_H
#define STRINGLIST_H

#include &lt;string&gt;

class StringList
{
public:
	StringList(void);
	StringList(const StringList&amp;);
	~StringList(void);

	void AddLine(string); //&lt;&lt;== Hier meckert der Kompiler
	void DelLine(int);

	int Length(void);

	string&amp; operator[](int);
	string&amp; operator=(const StringList&amp;);

private:
	string *list;
	int length;
};

#endif
</code></pre>
<p>Implementation:</p>
<pre><code class="language-cpp">#include &lt;cassert&gt;

#include &quot;StringList.h&quot;

StringList::StringList()
{
	list = NULL;
	length = 0;
}

StringList::StringList(cons StringList)
{

StringList::~StringList()
{
	if (list)
		delete []list;
}

void StringList::AddLine(string newline)
{
	string *temp = list;
	list = new string[length+1];

	for (int i = 0; i &lt; list.length; i++)
		list[i] = temp[i];

	list[length] = newline;

	length = length+1;
	delete []temp;
}

void StringList::DelLine(int line)
{
	assert(index &gt;= 0 &amp;&amp; index &lt; length);

	string *temp = list, *tmp = list;
	list = new string[length-1];
	int j = 0;

	for (int i = 0; i &lt; length-1; i++)
	{
		if (i == line)
			j++;
		else
		list[i] = tmp[j++];
	}

	length = length-1;
	delete temp;
}

int StringList::Length(void)
{
	return length;
}

string&amp; StringList::operator [](int index)
{
	assert(index &gt;= 0 &amp;&amp; index &lt; length);
	return list[index];
}

string&amp; StringList::operator =(const StringList&amp; source)
{
	if (this != &amp;source)
	{
		delete list;
		length = source.Length();
		list = new string[length];
		for (int i = 0; i &lt; length; i++)
			list[i] = source[i];
	}
	return *this;
}
</code></pre>
<p>Fehler:</p>
<pre><code>--------------------Configuration: test - Win32 Debug--------------------
Compiling...
main.cpp
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(13) : error C2061: syntax error : identifier 'string'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2143: syntax error : missing ';' before '&amp;'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(18) : error C2501: '[]' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2143: syntax error : missing ';' before '&amp;'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(19) : error C2501: '=' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2143: syntax error : missing ';' before '*'
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2501: 'string' : missing storage-class or type specifiers
c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(22) : error C2501: 'list' : missing storage-class or type specifiers
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(158) : error C2660: 'AddLine' : function does not take 1 parameters
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(166) : error C2660: 'AddLine' : function does not take 1 parameters
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(170) : error C2248: 'length' : cannot access private member declared in class 'StringList'
        c:\programme\microsoft visual studio\myprojects\parser\test\stringlist.h(23) : see declaration of 'length'
C:\Programme\Microsoft Visual Studio\MyProjects\Parser\test\main.cpp(172) : error C2664: 'DelPreWhitespace' : cannot convert parameter 1 from 'int' to 'class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

test.exe - 14 error(s), 0 warning(s)
</code></pre>
<p>es geht mir prinzipel erstmal nur um den ersten fehler, da ich denke, dass das problem, das dahinter steckt, das grundproblem ist.<br />
danke jetzt schon mal.</p>
<p>MamboKurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/946378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946378</guid><dc:creator><![CDATA[MamboKurt]]></dc:creator><pubDate>Tue, 20 Dec 2005 15:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 15:31:15 GMT]]></title><description><![CDATA[<p>string ist im Namespace std, also bitte std::string im Header und using namespace std; an den Anfang der Implementierung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/946382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946382</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Tue, 20 Dec 2005 15:31:15 GMT</pubDate></item><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 15:41:38 GMT]]></title><description><![CDATA[<p>danke<br />
hab schon lange nichts mehr damit gemacht.<br />
das funktioniert jetzt.</p>
<p>jetzt meckert er wegen unresolved external symbol:</p>
<pre><code>--------------------Configuration: test - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol &quot;public: __thiscall StringList::~StringList(void)&quot; (??1StringList@@QAE@XZ)
main.obj : error LNK2001: unresolved external symbol &quot;public: class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &amp; __thiscall StringList::operator[](int)&quot; (??AStringList@@QAEAAV?$basic_string@DU?$char_traits@D@st
d@@V?$allocator@D@2@@std@@H@Z)
main.obj : error LNK2001: unresolved external symbol &quot;public: int __thiscall StringList::Length(void)&quot; (?Length@StringList@@QAEHXZ)
main.obj : error LNK2001: unresolved external symbol &quot;public: void __thiscall StringList::AddLine(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;)&quot; (?AddLine@StringList@@QAEXV?$basic_string@DU?$char_traits@D@s
td@@V?$allocator@D@2@@std@@@Z)
main.obj : error LNK2001: unresolved external symbol &quot;public: __thiscall StringList::StringList(void)&quot; (??0StringList@@QAE@XZ)
Debug/test.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.

test.exe - 6 error(s), 0 warning(s)
</code></pre>
<p>in der main.cpp hab ich<br />
#include &quot;StringList.h&quot;</p>
<p>in der StringList.cpp hab ich auch<br />
#include &quot;StringList.h&quot;</p>
<p>is was falsch dran?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/946389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946389</guid><dc:creator><![CDATA[MamboKurt]]></dc:creator><pubDate>Tue, 20 Dec 2005 15:41:38 GMT</pubDate></item><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 15:45:47 GMT]]></title><description><![CDATA[<p>Du musst dem Linker sagen, er soll gefälligst die Objektdatei zu StringList.cpp dazulinken. Mit dem Programmcode hat das nichts zu tun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/946395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946395</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Tue, 20 Dec 2005 15:45:47 GMT</pubDate></item><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 16:34:56 GMT]]></title><description><![CDATA[<p>MamboKurt schrieb:</p>
<blockquote>
<p>also ich wollte mir eine conainerklasse bastel für string.</p>
</blockquote>
<pre><code class="language-cpp">typedef std::list&lt;std::string&gt; StringList;
// wobei du, deinem Code nach zu urteilen, eher folgendes suchst:
typedef std::vector&lt;std::string&gt; StringVector;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/946433</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946433</guid><dc:creator><![CDATA[finix]]></dc:creator><pubDate>Tue, 20 Dec 2005 16:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to syntax error : identifier &#x27;string&#x27; on Tue, 20 Dec 2005 16:48:43 GMT]]></title><description><![CDATA[<p>ja dass es sowas schon gibt is mir schon klar, aber ich will mir die halt mal selber basteln um mal wieder in form zu kommen.<br />
also das hat sich erledigt. funktioniert jetzt alles. hab vergessen die dateien dem projekt hinzuzufügen.</p>
<p>MamboKurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/946450</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/946450</guid><dc:creator><![CDATA[MamboKurt]]></dc:creator><pubDate>Tue, 20 Dec 2005 16:48:43 GMT</pubDate></item></channel></rss>