C++ 检查是否正确

C++ 检查是否正确,c++,c++11,C++,C++11,格式ISO标准草案 n3234表示: Two names are the same if — they are identifier s composed of the same character sequence, or 根据这个意思,检查这是否正确 class ABC{}; class abc{}; int ABC(){} int abc(){} int main(){ int abc; char ABC; } 根据上述陈述,

格式ISO标准草案

n3234表示:

Two names are the same if
— they are identifier s composed of the same character sequence, or
根据这个意思,检查这是否正确

class ABC{};
class abc{};
int ABC(){}
int abc(){}
int main(){
           int abc;
           char ABC;
         }
根据上述陈述,该程序是否正确

这个程序适合这个语句吗?(那个语句的意思是什么)


最后…解释一下其他的事情…我走了吗

C++承认大写和小写,所以上面的内容是一致的

ABC和ABC之间有区别,它们是完全不同的标识符。 但是,在现实世界中,不鼓励使用这种区别来生成唯一标识符,因为它实际上保证了在某个时候会将它们混淆

请注意

int abc();
int abc();
这是非法的,但是

int abc();
int ABC();

不是。

C++承认大写和小写,因此上述内容确实符合

ABC和ABC之间有区别,它们是完全不同的标识符。 但是,在现实世界中,不鼓励使用这种区别来生成唯一标识符,因为它实际上保证了在某个时候会将它们混淆

请注意

int abc();
int abc();
这是非法的,但是

int abc();
int ABC();
不是。

来自ISO/IEC 14882:2003(E)9.1.2-

类定义将类名引入定义它的作用域,并在封闭作用域中隐藏该名称的任何类、对象、函数或其他声明(3.3)。如果在一个范围内声明了一个类名,其中还声明了一个同名的对象、函数或枚举数,那么当两个声明都在该范围内时,只能使用详细的类型说明符(3.4.4)引用该类

[示例:

struct stat { 
   // ...
};

stat gstat;    // use plain stat to 
               // define variable

int stat(struct stat*);   // redeclare stat as function

void f() {
    struct stat* ps; stat(ps);   // struct prefix needed 
                                 // to name struct stat 
                                 // ...
}
-[结束示例]

3.3.7名称隐藏

2类名(9.1)或枚举名(7.2)可以通过在同一范围内声明的对象、函数或枚举器的名称隐藏。如果类或枚举名称以及对象、函数或枚举数在同一作用域中以相同名称(以任何顺序)声明,则无论对象、函数或枚举数名称在何处可见,该类或枚举名称都将隐藏


引用标准,所有这些陈述都是正确的

class ABC{};
class abc{};   // abc and ABC are two different character sequences for the 
               // class entity. And similar is the case for next two function
               // entities.

int ABC(){} 
int abc(){}

int main(){      
    int abc;   // abc and ABC are two different character sequences.
    char ABC;
}
最后…解释一下其他的事情…我走了吗

这两个函数
ABC(),ABC()
都应该返回
int
,但它们没有这样做:)

来自ISO/IEC 14882:2003(E)9.1.2-

类定义将类名引入定义它的作用域,并在封闭作用域中隐藏该名称的任何类、对象、函数或其他声明(3.3)。如果在一个范围内声明了一个类名,其中还声明了一个同名的对象、函数或枚举数,那么当两个声明都在该范围内时,只能使用详细的类型说明符(3.4.4)引用该类

[示例:

struct stat { 
   // ...
};

stat gstat;    // use plain stat to 
               // define variable

int stat(struct stat*);   // redeclare stat as function

void f() {
    struct stat* ps; stat(ps);   // struct prefix needed 
                                 // to name struct stat 
                                 // ...
}
-[结束示例]

3.3.7名称隐藏

2类名(9.1)或枚举名(7.2)可以通过在同一范围内声明的对象、函数或枚举器的名称隐藏。如果类或枚举名称以及对象、函数或枚举数在同一作用域中以相同名称(以任何顺序)声明,则无论对象、函数或枚举数名称在何处可见,该类或枚举名称都将隐藏


引用标准,所有这些陈述都是正确的

class ABC{};
class abc{};   // abc and ABC are two different character sequences for the 
               // class entity. And similar is the case for next two function
               // entities.

int ABC(){} 
int abc(){}

int main(){      
    int abc;   // abc and ABC are two different character sequences.
    char ABC;
}
最后…解释一下其他的事情…我走了吗

这两个函数
ABC(),ABC()
都应该返回
int
,但它们没有这样做:)

int ABC();int abc()实际上并不非法。它只是重新定义了相同的功能。(这种重新声明可以很容易地通过正向声明实现。)
int abc();int abc()实际上并不非法。它只是重新定义了相同的功能。(这种重新声明很容易通过远期声明实现。)