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.

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe per Konsole ein Programm gebastelt zur Berechnung von Brüchen. Das ganze halt mit Klassen. Nun wollte ich das Proggy als MFC Windows Programm portieren. Ich habe die Header Datei und die cpp Datei eingebunden und bekomme jetzt diese Fehlermeldung: "fatal error C1010: Unerwartetes Dateiende waehrend der Suche nach der Direktive fuer die vorkompilierte Header-Datei". Meine Header Datei: #include <iostream.h>

#include "stdafx.h"

class ratio{

private:

int z;

int n;

void rkuerzen();

public:

ratio(const ratio&);

ratio& operator = (ratio&);

ratio(int za=0, int na=1);

~ratio();

//void print();

ratio operator+(ratio&);

ratio operator-(ratio&);

ratio operator/(ratio&);

ratio operator*(ratio&);

bool setratio(int za, int na);

friend ostream& operator<<(ostream& o, ratio & r); //Friendfunktion

friend istream& operator>>(istream& i, ratio & r); //Friendfunktion

};

Meine cpp Datei:

#include "cratio.h"

/*void ratio: :print(){

cout<<z;

cout<<'/';

cout<<n<<" ";

}*/

bool ratio::setratio(int za,int na){

z=za;

if(na==0)

return false; //Nenner ist 0 - Fehler

else{

n=na;

rkuerzen(); /*direkter Aufruf mit interner Bindung zu dem Objekt,

welches setratio gerufen hat*/

return true; //Alles OK

}

}

ratio & ratio: :operator =(ratio& op2){

z=op2.z;

n=op2.n;

return(*this);

}

ratio ratio: :operator + (ratio& op2){

ratio erg;

erg.z=z * op2.n + op2.z * n;

erg.n=n * op2.n;

erg.rkuerzen();

return erg;

}

ratio ratio: :operator - (ratio& op2){

ratio erg;

erg.z=z * op2.n - op2.z * n;

erg.n=n * op2.n;

erg.rkuerzen();

return erg;

}

ratio ratio: :operator * (ratio& op2){

ratio erg;

erg.z=z * op2.z;

erg.n=n * op2.n;

erg.rkuerzen();

return erg;

}

ratio ratio: :operator / (ratio& op2){

ratio erg;

erg.z=z * op2.n;

erg.n=n * op2.z;

erg.rkuerzen();

return erg;

}

int absB(int zahl){

if(zahl<0)

return (-zahl);

else

return(zahl);

}

void ratio::rkuerzen(){

int gmt, teiler;

if(n<0){

z=-z;

n=absB(n);

}

if(z==0)

n=1;

if (absB(z)<absB(n))

gmt=absB(z);

else

gmt=absB(n);

for(teiler=2;teiler<=gmt;teiler++){

if((z%teiler==0)&&(n%teiler==0)){

z=z/teiler;

n=n/teiler;

teiler--;

}

}

}

ostream& operator <<(ostream& o, ratio & r){

o<< r.z <<'/'<< r.n;

return o;

}

istream& operator>>(istream& i, ratio & r){

int a,b;

cout<<"Eingabe Zaehler: ";

i>>a;

do{

cout<<"Eingabe Nenner: ";

i>>b;

}while (!r.setratio(a,B));

return i;

}

ratio::ratio(int za, int na){

z=za;

n=na;

rkuerzen();

}

ratio::~ratio(){

}

ratio::ratio(const ratio&ob){

z=ob.z;

n=ob.n;

}

Danke für die Hilfe.

Gruß Sven

Das #include "stdafx.h" muss aus der Headerdatei raus und in die cpp-Datei rein.

Falls das nicht hilft:

(Hab's hier leider nur auf Englisch, also nagel mich nicht auf die genauen Worte fest)

Projekt->Einstellungen->(Deine cpp-Datei auswählen)->Register "C/C++".

In der Listbox "vorkompilierte Header" auswählen, dann den ersten Punkt ("nicht benutzen") auswählen.

Ach ja, #include "stdafx.h" sollte immer vor allen anderen #includes stehen

<FONT COLOR="#a62a2a" SIZE="1">[ 16. November 2001 09:27: Beitrag 4 mal editiert, zuletzt von Klotzkopp ]</font>

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.