Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Fehler C2659 Funktion als linker Operant

Empfohlene Antworten

Veröffentlicht

Hallo,

ich schreibe für die Schule eine Projektarbeit in C++ und ich programmiere ein Taschenrechner mit Visual C++ Studio 2008 Express Edition. Jetz bin ich fast fertig mit dem Programm hat auch alles gut funktioniert, aber zum Schluss taucht der Fehler auf " error C2659: "=": Funktion als linker Operand".

Hier mein Code:

#pragma once

namespace Taschenrechner {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

public ref class Form1 : public System::Windows::Forms::Form

{

public:

bool static operation = true;

double Zahl1;

double Zahl2;

double Ergebnis;

char Rechenart;

private: System::Windows::Forms::Button^ button6;

public:

Form1(void)

{

InitializeComponent();

//

//TODO: Konstruktorcode hier hinzufügen.

//

}

protected:

/// <summary>

/// Verwendete Ressourcen bereinigen.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

#pragma endregion

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "1";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "1";

}

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "2";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "2";

}

}

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "3";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "3";

}

}

private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "4";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "4";

}

}

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "5";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "5";

}

}

private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "6";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "6";

}

}

private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "7";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "7";

}

}

private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "8";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "8";

}

}

private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "9";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "9";

}

}

private: System::Void button0_Click(System::Object^ sender, System::EventArgs^ e)

{

if (textBox1->Text == "0")

{

return;

}

else

{

textBox1->Text = textBox1->Text + "0";

}

}

private: System::Void Komma_Click(System::Object^ sender, System::EventArgs^ e)

{

if (textBox1->Text->Contains(","))

{

return;

}

else

{

textBox1->Text = textBox1->Text + ",";

}

}

private: System::Void Clear_Click(System::Object^ sender, System::EventArgs^ e)

{

textBox1->Text = "";

}

private: System::Void Addition_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 43;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Subtraktion_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 45;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Multiplikation_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 42;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Division_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 47;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Gleich_Click(System::Object^ sender, System::EventArgs^ e)

{

textBox1->Text = Zahl2.ToString();

operation = true;

switch (Rechenart)

{

case char(43):

Ergebnis=Zahl1+Zahl2;

break;

case char(45):

Ergebnis=Zahl1-Zahl2;

break;

case char(42):

Ergebnis=Zahl1*Zahl2;

break;

case char(47):

Ergebnis=Zahl1/Zahl2;

break;

default: "" ;

break;

}

Ergebnis.ToString = textBox1->Text;

}

};

}

Der Fehler taucht bei der letzten Zeile auf, die ich programmiert habe "Ergebnis.ToString = textBox1->Text;". Dort versuche ich Das Ergebnis was errechnet wurde in der Textbox auszugeben.

Hoffe ihr könnt mir helfen.

MfG Steffen

ok der Fehler kommt nicht mehr hab jetzt textBox1->Text = Ergebnis.ToString;

aber das Programm funktioniert nicht richtig wenn ich 2 Zahlen addiere, subtrahiere, multipliziere oder dividiere und dann auf gleich drücke wird mir in der Textbox der Wert 0 angezeigt.

Weiß jemand was ich falsch gemacht habe?

kannste mir sagen wie ich denn zahl1 und zahl2 den wert aus der textbox zuweisen kann?

dann kommt diese Fehlermeldung:

warning C4832: Das Token '.' ist nach UDT 'System::Convert' illegal

c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll: Siehe Deklaration von 'System::Convert'

und diese:

error C2275: 'System::Convert': Ungültige Verwendung dieses Typs als Ausdruck

c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll: Siehe Deklaration von 'System::Convert'

thx funktioniert einwandfrei

wollte das Programm jez erweitern

mit ner quadrierung, also x² aba ich finde nich den befehl den ich dafür brauche?

gibt es da keinen bestimmten befehl in c++?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.