C2653

错误消息

“identifier”: 不是类或命名空间名称

语法需要类、结构、联合或命名空间名称。

下面的示例生成 C2653:

   
// C2653.cpp
// compile with: /c
class yy {
   void func1(int i);
};

void xx::func1(int m) {}   // C2653
void yy::func1(int m) {}   // OK

如果尝试定义复合命名空间,也可能会发生 C2653;C++ 中不允许复合命名空间:

   
// C2653b.cpp
namespace a::b {int i;}   // C2653

namespace a {
   namespace b {
      int i;
   }
}

int main() {
   a::b::i = 2;
}

避免头文件重复引用
//#pragma once


#ifndef _xxx_H
#define _xxx_H

Class{};

#endif

用#ifndef _xxx_H   #define _xxx_H  。。。#endif的时候  ifndef少个“n”也会造成则个错误   记录下
展开阅读全文

error C2653: 'iso_base' : is not a class or namespace name

11-27

//brass.hrnrn#ifndef BRASS_H_rn#define BRASS_H_rnrnclass Brassrnrnprivate:rn static const int MAX = 35;rn char fullname[MAX];rn long acctNum;rn double balance;rnpublic:rn Brass(const char *s = "nullbody", long an = -1, double bal = 0.0);rn void Deposit(double amt);rn virtual void Withdraw(double amt);rn double Balance()const;rn virtual void ViewAcct()const;rn virtual ~Brass()rn;rnrn//Brass plus Account classrnrnclass BrassPlus:public Brassrnrnprivate:rn double maxLoan;rn double rate;rn double owesBank;rnrnpublic:rn BrassPlus(const char *s = "nullbody", long an = -1,rn double bal = 0.0, double ml = 500, double r = 0.10);rn BrassPlus(const Brass &ba, double ml = 500, double r = 0.1);rnrn virtual void ViewAcct()const;rn virtual void Withdraw(double amt);rn rn void ResetMax(double m) maxLoan = m; rn void ResetRate(double r) rate = r; rn rn void ResetOwes() owesBank = 0; rnrn;rn#endifrnrnrnrnrn//brass.cpprnrn#includern#includernusing namespace std;rnrn#include "brass.h"rnrnrnBrass::Brass(const char *s, long an, double bal)rnrn strncpy(fullname, s, MAX - 1);rn fullname[MAX - 1];rn acctNum = an;rn balance = bal;rnrnrnrnrnvoid Brass::Deposit(double amt)rnrn if( amt < 0)rn rn cout << "negative deposit not allowed, withdrawal canceled\n";rn rn rn elsern rn balance += amt;rn rnrnrnvoid Brass::Withdraw(double amt)rnrn if(amt < 0)rn rn cout << "negative deposit not allowed;"rn << "withdrawal canceled \n";rn rn else if( amt <= balance)rn rn balance -= amt;rn rn elsern rn cout <<"withdrawal amount of $" << amtrn << "exceed your balance \n" rn <<"withdrawal cancelled. \n";rn rnrnrndouble Brass::Balance() constrnrn return balance;rnrnrnvoid Brass::ViewAcct() constrnrn iso_base::fmtflags initialState = cout.setf(iso_base::fixed, iso_base::floatfield);rn cout.setf(iso_base::showpoint);rn cout.precision(2);rnrnrn cout << "client : " < There is no context in which this conversion is possiblern~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~rn这个warming c4996 为什么老出现 我已经包含了 #include 了,我用VC6的时候 没这个警告rn然后是是'iso_base' : is not a class or namespace namern我对过代码了,没发现问题在哪里!rnrn希望能得到以上三个错误的 原因!!rn谢谢!!!rn~~~~~~~~~~~~~~~~~~~~~~rnrn 论坛

很多错:error C2653: 'CHbGisDoc' : is not a class or namespa

07-22

#include rn#include rn#include rnrnrnrnBOOL CHbGisDoc::OnNewDocument()rnrn if (!CDocument::OnNewDocument())rn return FALSE;rn //add new map documentrn CHbGisView* view = GetMainView();rn if(View == NULL)rn return FALSE;rn RECT windRect;rn view->GetClientRect(&windRect);rn //get the file "chengdu.gst" pathrn char clientpath[121];rn GetCurrentDirectory(120, clientpath);rn CString tempclientpath;rn tempclientpath.Format("C:\\cut\\map.gst",clientpath);rn CMapX m_map;rn //map view is createdrn if(m_map.Create(NULL, WS_VISIBLE, windRect, view, IDC_MAP))rn rn m_map.SetGeoSet(tempclientpath);rn rn elsern rn return FALSE;rn rn return TRUE;rnrn显示错误:rnccc_map.cpprnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(7) : error C2653: 'CHbGisDoc' : is not a class or namespace namernd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(9) : error C2352: 'CDocument::OnNewDocument' : illegal call of non-static member functionrn d:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(4488) : see declaration of 'OnNewDocument'rnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(12) : error C2065: 'CHbGisView' : undeclared identifierrnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(12) : error C2065: 'view' : undeclared identifierrnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(12) : error C2065: 'GetMainView' : undeclared identifierrnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(12) : error C2106: '=' : left operand must be l-valuernd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(13) : error C2065: 'View' : undeclared identifierrnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(16) : error C2227: left of '->GetClientRect' must point to class/struct/unionrnd:\program files\microsoft visual studio\myprojects\cc_map\ccc_map.cpp(24) : error C2065: 'IDC_MAP' : undeclared identifierrnError executing cl.exe.rnrn请指教!!!!谢谢谢谢!!!! 论坛

没有更多推荐了,返回首页