社区
C++ 语言
帖子详情
error C2059: syntax error : '.'
andyfr1210
2004-07-31 12:04:19
我在调用一个类里的函数时出现这个错误:checking.count()
整个程序就这一个错误,不知道是什么原因引起的.
有谁知道吗?
...全文
197
10
打赏
收藏
error C2059: syntax error : '.'
我在调用一个类里的函数时出现这个错误:checking.count() 整个程序就这一个错误,不知道是什么原因引起的. 有谁知道吗?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Dong
2004-07-31
打赏
举报
回复
checking.count()
checking->count()
andyfr1210
2004-07-31
打赏
举报
回复
up一下.
summer6074
2004-07-31
打赏
举报
回复
劳驾把代码贴齐
andyfr1210
2004-07-31
打赏
举报
回复
不是下面这个原因:
这里有两个CPP文件,而
--------------------Configuration: 069 - Win32 Debug--------------------
Compiling...
069.cpp
D:\vc++程序设计\069\069.cpp(8) : error C2059: syntax error : '.'
Error executing cl.exe.
069.exe - 1 error(s), 0 warning(s)
这里很明显只编译了一个文件。
应该把两个CPP文件加入一个工程。
andyfr1210
2004-07-31
打赏
举报
回复
我知道是什么原因了.
因为预处理的:#ifndef checking
#define checking
#endif
的标志与定义的类的对象Checking checking名重复了,只要将对象改名为:Checking checking1就可以了..................................
zouxueping
2004-07-31
打赏
举报
回复
这里有两个CPP文件,而
--------------------Configuration: 069 - Win32 Debug--------------------
Compiling...
069.cpp
D:\vc++程序设计\069\069.cpp(8) : error C2059: syntax error : '.'
Error executing cl.exe.
069.exe - 1 error(s), 0 warning(s)
这里很明显只编译了一个文件。
应该把两个CPP文件加入一个工程。
andyfr1210
2004-07-31
打赏
举报
回复
up一下.
Dong
2004-07-31
打赏
举报
回复
我觉得楼主的问题是类Checking没有被好好的编译成功。也许你要包含的是checking.cpp文件,被.h该成.cpp看看吧。
我用一个文件编译你上面的三个文件没有出现问题。
结果为1。
andyfr1210
2004-07-31
打赏
举报
回复
是钱能上C++上的一个例子.
andyfr1210
2004-07-31
打赏
举报
回复
//check.h
#ifndef checking
#define checking
enum REMIT{remitByPost,remitByCable,other};
class Checking
{
public:
Checking(int accNo,float balan=0.0);
int AccountNo();
float AcntBalan();
static Checking* First();
Checking* Next();
static int NoAccounts();
void Display();
void Deposit(float amount);
void Withdrawal(float amount);
void SetRemit(REMIT re);
protected:
static Checking* pFirst;
Checking* pNext;
static int count;
int acntNumber;
float balance;
REMIT remittance;
};
#endif
//checking.cpp
#include<iostream.h>
#include"checking.h"
Checking* Checking::pFirst=0;
int Checking::count=0;
Checking::Checking(int accNo,float balan)
{
acntNumber=accNo;
balance=balan;
remittance=other;
count++;
if(pFirst==0)
pFirst=this;
else
{
Checking* ps=pFirst;
for(;ps->pNext;ps=ps->pNext) ;
ps->pNext=this;
}
pNext=0;
}
int Checking::AccountNo()
{
return acntNumber;
}
float Checking::AcntBalan()
{
return balance;
}
Checking* Checking::First()
{
return pFirst;
}
Checking* Checking::Next()
{
return pNext;
}
int Checking::NoAccounts()
{
return count;
}
void Checking::Display()
{
cout<<"Checking account number:"<<acntNumber
<<"="<<balance<<endl;
}
void Checking::Deposit(float amount)
{
balance+=amount;
}
void Checking::Withdrawal(float amount)
{
float temp=amount;
if(remittance==remitByPost)
temp=amount+30;
else if(remittance==remitByCable)
temp=amount+60;
if(balance<temp)
cout<<"Insufficient funds:balance "<<balance
<<",withdrawal "<<temp<<endl;
else
balance-=temp;
}
void Checking::SetRemit(REMIT re)
{
remittance=re;
}
//main.cpp
#include<iostream.h>
#include"checking.h"
void main()
{
Checking checking(1001,1001);
cout<<checking.NoAccounts()<<endl;
}
--------------------Configuration: 069 - Win32 Debug--------------------
Compiling...
069.cpp
D:\vc++程序设计\069\069.cpp(8) : error C2059: syntax error : '.'
Error executing cl.exe.
069.exe - 1 error(s), 0 warning(s)
不管换哪个函数都是一样的错误!
c语言错误代码
c2059
syntax
,突然出现错误gdiplustypes.h(280):
error
C2059
:
syntax
error
: 'constant'等未知错误(示例代码)...
gdiplustypes.h(280):
error
C2059
:
syntax
error
: ‘constant‘gdiplustypes.h(280):
error
C2238: unexpected token(s) preceding ‘;‘gdiplustypes.h(281):
error
C2059
:
syntax
error
: ‘constant...
error
C2059
:
syntax
error
: 'constant'
error
C2059
:
syntax
error
: 'constant'
C语言编程之错误一:
error
C2059
:
syntax
error
: ‘)’
error
C2059
:
syntax
error
: ‘)’
syntax
意思是语法,所以就是语法错误。 这类问题一般都是语法问题,不改写括号写括号啦,变量名写错啦什么的,不知道就看‘ ‘内的内容,基本都是相关的。
signal.h(62,94):
error
C2059
:
syntax
error
: ‘;‘
>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\signal.h(62,94):
error
C2059
:
syntax
error
: ';'
error
C2059
:
syntax
error
: '!'和
error
C2043: illegal break
在C语言中遇到的问题
error
C2059
:
syntax
error
: '!'和
error
C2043: illegal break #include #include /********found********/ IsPrime(int n){ int i, m; m = 1; /********found********/ for (i=2; i; i...
C++ 语言
64,645
社区成员
250,475
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章