声明终止cpp中的以下代码中出现错误
Declaration terminated Incorrectly error in following code in cpp
我正试图为观察者模式开发C++程序,但我遇到了这些错误。这是我的CPP代码,我不断地收到错误:"声明终止错误"!提前感谢请帮帮我,我绝望了。
#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 :nn1) Depositn2)Withdrawln";
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 Transitionn";
cout<<"nEnter the Details of Account Holder :-n";
balance = ac.attach();
cout<<"nCall notification for Deposit or Withdrawl Transitionn";
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();
}
}
在类声明的末尾缺少一个;
。正确:
class Foo
{
/*...*/
};
在C++
中,main
应该是一个自由函数,obpt
类是错误的。
int main()
{
/* ... */
}
您收到的错误消息来自编译器。声明声明语句没有正确结束。
在代码的某个地方,您缺少了一个分号;可能在类声明的末尾,或者在定义变量之后。
如果没有看到你的代码,我就无法确定问题所在,但如果你双击它,错误消息应该会把你带到行!
问候,拉凯什。
相关文章:
- 将鼠标悬停在问题上时与预期">"相关的代码错误
- VI工作室代码错误无法打开输出文件主.exe
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- 有关矩阵的代码错误导致分段错误(内核转储)
- C++ Schannel POST 400 错误代码错误请求
- Java 本机访问代码错误:"Invalid memory access"
- 代码错误修改
- C++代码错误分配
- "_FCbuild"不能用作函数 - C/C++ 代码错误
- 我的代码错误类型警告 1 警告 C4018 和更多错误
- 代码错误(从 1 到 100 找到质数)
- OpenCV VisualStudio,C 代码错误尝试访问像素
- 当我使用的教程完全没有错误时,为什么我的代码错误
- 简单的NOOB C 输入/输出问题:代码错误
- 为什么enumProcessModules返回false值和299代码错误
- WinhttpSetoption()失败设置TLSV1.2,带有错误代码错误_internet_incorrect_ha
- 苹果安全传输代码错误
- C++ - 国际象棋主教移动代码错误
- 导入Python库时,嵌入了Python代码错误
- 编译提升C 代码错误