Erklärung gekündigt Falsch Fehler in folgenden code in cpp
Iam, der versucht, sich zu entwickeln C++ - Programm für observer-Muster, aber ich bin immer diese Fehler.
Hier ist meine CPP-code , und ich immer Fehler ständig : "Erklärung der Kündigung falsch" !
Vielen Dank im Voraus
Helfen Sie mir bitte ich bin verzweifelt.
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class Subject{
public : virtual ~Subject();
virtual float attach()=0;
virtual int notify()=0;
};
class Observer{
public : virtual ~Observer();
virtual void update(int type, float amount, float bal)=0;
};
class Account : public Subject
{
public: float attach()
{
char name[12];
int account_no;
float bal;
cout<<"Enter the Name of Account Holder : ";
cin>>name;
cout<<"Enter the Account No. : ";
cin>>account_no;
cout<<"Enter the Balance of his account : ";
cin>>bal;
cout<<"The Name of Account Holder : "<<name;
cout<<"The Account No. : "<<account_no;
cout<<"The Balance of his account : "<<bal;
return bal;
}
int notify()
{
int type;
cout<<"\nMenu :\n\n1) Deposit\n2)Withdrawl\n";
cout<<"Enter the type for transition : \n";
cin>>type;
return type;
}
public: void update(int type, float amount, float bal)
{
char name[12];
int account_no;
if(type==1)
bal=bal+amount;
else if(type==2)
bal=bal-amount;
else
cout<<"Oops! Transition Type is invalild....";
cout<<"\nThe Details of Account Holder after Transition :-\n";
cout<<"The Name of Account Holder : "<<name;
cout<<"The Account No. : "<<account_no;
cout<<"The Balance of his account : "<<bal;
}
};
class obpt{
public : static void main()
{
Account ac;
//AccountUpdate au;
float balance, amt;
int type;
clrscr();
cout<<"\nWelcome To The Program of Observer Pattern of Account Transition\n";
cout<<"\nEnter the Details of Account Holder :-\n";
balance = ac.attach();
cout<<"\nCall notification for Deposit or Withdrawl Transition\n";
type=ac.notify();
cout<<"\nEnter the amount for transition : \n";
cin>>amt;
cout<<"\nAfter The transition the Main balance : \n";
ac.update(type, amt, balance);
getch();
}
}
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihnen fehlen
;
am Ende der Klassendeklaration. Richtig:In
C++
,main
sollte eine freie Funktion, dieobpt
- Klasse falsch ist.Die Fehlermeldung, die Sie empfangen, kommt aus dem compiler. Es besagt, dass eine Zollerklärung wurde nicht ordnungsgemäß beendet.
Irgendwo in deinem code fehlt ein Semikolon ; vielleicht am Ende der Deklaration einer Klasse oder nachdem eine variable definiert ist.
Ohne zu sehen, Ihren code, es gibt keine Möglichkeit für mich, zu lokalisieren das problem, sondern die Fehlermeldung sollten Sie auf der Linie, wenn Sie doppelt darauf klicken!
Grüße, Rakesh.