2-10-2 "block scope" for classes and namespaces

Moderators: david ward, misra cpp

abgs
Posts: 11
Joined: Wed Sep 06, 2017 4:25 pm
Company: Gimpel Software

2-10-2 "block scope" for classes and namespaces

Postby abgs » Thu Feb 14, 2019 11:11 am

Rule 2-10-2 is defined in terms of "block scopes" and "nested blocks". The only example is of a function and there is no mention of classes nor namespaces. Does "block" refer only to a compound statement as part of a function body, or is the intention to include other curly-brace-enclosed regions or scopes? For example, are any of the indicated lines violations of rule 2-10-2?

Code: Select all

int i;
namespace n { int i; } // A
namespace { int i; } // B
class c { int i; }; // C

class c2 { int k; void f() { int k; } }; // D

class base { int z; };
class derived : public base { int z; }; // E


Return to “6.2 Lexical conventions (C++)”

Who is online

Users browsing this forum: No registered users and 1 guest