<?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[Vererbung von Klassen -&amp;gt; Konstructor]]></title><description><![CDATA[<p>Hey also hier mein Problem:<br />
Ich zeichne normale Tasten mit einer Klasse bei denen Parameter im Konstruktor übergeben werden sollen. jetzt möchte ich noch spezielle Tasten einbauen. Also benutze ich eine abgeleitete Klasse. Nur irgendwie kommt immer die Fehlermeldung &quot;Kein geeigneter Standtartkonstruktor&quot;. Ich habe schon alles versucht.</p>
<pre><code class="language-cpp">#pragma once

#include &quot;Textur.h&quot;

class CKey
{
public:
	CKey(int kk,float rr,float gg,float bb, char cc, char *f);
	virtual ~CKey(void);

	CTextur *textur;

	void draw();

	float width,height;
	char character;
	char *file;
	float r,g,b;
	int key;

private:
	virtual void _draw();
	void init();

	bool setup;
};

class CspaceKey : public CKey
{
public:
	CspaceKey(int kk,float rr,float gg,float bb, char cc, char *f);
	virtual ~CspaceKey(void);

	void _draw();
};
</code></pre>
<p>das ist mein Kopf</p>
<pre><code class="language-cpp">#include &quot;Key.h&quot;
#include &lt;stdlib.h&gt;
#include &quot;glut.h&quot;

CKey::CKey(int kk,float rr,float gg,float bb, char cc,char *f)
{
	key = kk;
	r = rr;
	g = gg;
	b = bb;
	width = 1.0/12;
	height = 1.0/5;
	character = cc;
	file = f;
	setup = true;
}

CKey::~CKey(void)
{
}

void CKey::init() 
{
	textur = new CTextur();
	textur-&gt;load(file);
}

void CKey::draw()
{
	if(setup)
	{
		init();
	    setup = false;
	}

	if(key == 1)
	{
		glColor3f(r,g,b);
		glPushMatrix();
		textur-&gt;bind();
		glBegin(GL_QUADS);
			glVertex2f(0,0);
			glVertex2f(0,height);
			glVertex2f(width,height);
			glVertex2f(width,0);
		glEnd();
		textur-&gt;unbind();
		glPopMatrix();
		glTranslatef(width,0,0.0f);
	}
	else if(key == 2)
	{
	    this-&gt;_draw();
	}
}

void CKey::_draw()
{

}

CspaceKey::CspaceKey(int kk,float rr,float gg,float bb, char cc,char *f)
//: CKey(kk) etc. auch versucht aber keinen Erfolg
{

}

CspaceKey::~CspaceKey(void)
{

}

void CspaceKey::_draw()
{
	glColor3f(r,g,b);
	glPushMatrix();
	textur-&gt;bind();
	glBegin(GL_QUADS);
		glVertex2f(0,0);
		glVertex2f(0,height);
		glVertex2f(width,height);
		glVertex2f(width,0);
	glEnd();
	textur-&gt;unbind();
	glPopMatrix();
	glTranslatef(width,0,0.0f);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/198722/vererbung-von-klassen-gt-konstructor</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 14:17:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198722.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 Nov 2007 17:51:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vererbung von Klassen -&amp;gt; Konstructor on Sat, 24 Nov 2007 17:52:22 GMT]]></title><description><![CDATA[<p>Hey also hier mein Problem:<br />
Ich zeichne normale Tasten mit einer Klasse bei denen Parameter im Konstruktor übergeben werden sollen. jetzt möchte ich noch spezielle Tasten einbauen. Also benutze ich eine abgeleitete Klasse. Nur irgendwie kommt immer die Fehlermeldung &quot;Kein geeigneter Standtartkonstruktor&quot;. Ich habe schon alles versucht.</p>
<pre><code class="language-cpp">#pragma once

#include &quot;Textur.h&quot;

class CKey
{
public:
	CKey(int kk,float rr,float gg,float bb, char cc, char *f);
	virtual ~CKey(void);

	CTextur *textur;

	void draw();

	float width,height;
	char character;
	char *file;
	float r,g,b;
	int key;

private:
	virtual void _draw();
	void init();

	bool setup;
};

class CspaceKey : public CKey
{
public:
	CspaceKey(int kk,float rr,float gg,float bb, char cc, char *f);
	virtual ~CspaceKey(void);

	void _draw();
};
</code></pre>
<p>das ist mein Kopf</p>
<pre><code class="language-cpp">#include &quot;Key.h&quot;
#include &lt;stdlib.h&gt;
#include &quot;glut.h&quot;

CKey::CKey(int kk,float rr,float gg,float bb, char cc,char *f)
{
	key = kk;
	r = rr;
	g = gg;
	b = bb;
	width = 1.0/12;
	height = 1.0/5;
	character = cc;
	file = f;
	setup = true;
}

CKey::~CKey(void)
{
}

void CKey::init() 
{
	textur = new CTextur();
	textur-&gt;load(file);
}

void CKey::draw()
{
	if(setup)
	{
		init();
	    setup = false;
	}

	if(key == 1)
	{
		glColor3f(r,g,b);
		glPushMatrix();
		textur-&gt;bind();
		glBegin(GL_QUADS);
			glVertex2f(0,0);
			glVertex2f(0,height);
			glVertex2f(width,height);
			glVertex2f(width,0);
		glEnd();
		textur-&gt;unbind();
		glPopMatrix();
		glTranslatef(width,0,0.0f);
	}
	else if(key == 2)
	{
	    this-&gt;_draw();
	}
}

void CKey::_draw()
{

}

CspaceKey::CspaceKey(int kk,float rr,float gg,float bb, char cc,char *f)
//: CKey(kk) etc. auch versucht aber keinen Erfolg
{

}

CspaceKey::~CspaceKey(void)
{

}

void CspaceKey::_draw()
{
	glColor3f(r,g,b);
	glPushMatrix();
	textur-&gt;bind();
	glBegin(GL_QUADS);
		glVertex2f(0,0);
		glVertex2f(0,height);
		glVertex2f(width,height);
		glVertex2f(width,0);
	glEnd();
	textur-&gt;unbind();
	glPopMatrix();
	glTranslatef(width,0,0.0f);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409483</guid><dc:creator><![CDATA[Lenni]]></dc:creator><pubDate>Sat, 24 Nov 2007 17:52:22 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung von Klassen -&amp;gt; Konstructor on Sat, 24 Nov 2007 18:33:34 GMT]]></title><description><![CDATA[<p>Du mußt beim Konstruktor den passenden Basisklassen-Konstruktor aufrufen:</p>
<pre><code class="language-cpp">CspaceKey::CspaceKey(int kk,float rr,float gg,float bb, char cc,char *f) 
  : CKey(kk, rr, gg, bb, cc, f)
{
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409500</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409500</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Sat, 24 Nov 2007 18:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to Vererbung von Klassen -&amp;gt; Konstructor on Sat, 24 Nov 2007 19:09:40 GMT]]></title><description><![CDATA[<p>oh man ich bin so blöd^^</p>
<p>aber danke für deine Hilfe <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/1409526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409526</guid><dc:creator><![CDATA[Lenni]]></dc:creator><pubDate>Sat, 24 Nov 2007 19:09:40 GMT</pubDate></item></channel></rss>