Is class member declaration not a statement?

Selman Genç

I thought the class member declarations are declaration statements. But when I look at the declaration statements from the spec. I found this:

declaration-statement:
      local-variable-declaration;
      local-constant-declaration;

Obviously a class member declaration neither local variable nor local constant. So, what is the correct term for a class member declaration? There is no separate chapter for class member declarations in the Statements section, so are they not statements? if they are which category do they belong to?

mathk

declaration statement can be seen as a subset of declaration. Eventually declaration statement is the intersection of statement and declaration.

Now concerning members, you have to know which kind of member you are dealing with. For class you have class member declaration etc...

By reading your comment I think you are getting confused with the term statement. In a language, a statement should be a computable thing. C# does not strictly follow these rules (many other language also do not). To enhance the declaration statement.

For example:

int i;
int i = 0;

Both are a declaration statement. The computational part is the allocation in the heap space and/or the initialization of the value. To simplify a declaration is something that will be use in the lexical scope analyzer and/or the linker. But, a statement is something mainly used in the bytecode emitter

Going back to member declaration. You could argue that a member declaration can embed computation and be correct. For example:

class a { static int i = 42;}

Alas again C# is not strictly following the definition and should have named this a class-member-declaration-statement. But the name becomes silly and not all statements are accepted in class member declarations.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Class has no member "Class"

분류에서Dev

"syntax error, unfinished class declaration"

분류에서Dev

Lambda function as class member

분류에서Dev

Member in child class a reference to parent member?

분류에서Dev

Using getline with ifstream class member

분류에서Dev

Issue with declaration of Map<String,Class<? extends Serializable>>

분류에서Dev

Where is declaration of invoke method in Delegate class?

분류에서Dev

Python: Hide member of base class in derived class

분류에서Dev

Creating a class instance as a member of another class

분류에서Dev

accessing the member of a class of pointer array of another class

분류에서Dev

Passing a member function of a class to a parameter outside the class

분류에서Dev

`In instantiation of [template class] [member] is protected [. . .] [public member] is inaccessible'

분류에서Dev

jQuery if statement change div class to another not class

분류에서Dev

Difference in Use statement outside class / inside class

분류에서Dev

Is it possible to define a virtual static member on a delphi class?

분류에서Dev

Call member function when class type is not known

분류에서Dev

Serializable class with unserializable injected member in JAVA

분류에서Dev

Cannot access private member declared in class

분류에서Dev

Forcing initialization of static data member of template class

분류에서Dev

C++ class member check if not a template

분류에서Dev

Resolve ambiguousness of a base template class member

분류에서Dev

my class does not have a member property

분류에서Dev

What is the difference between private and private[Class] declaration in scala?

분류에서Dev

Drools variable declaration in condition depending on class type using "not"

분류에서Dev

Box iOS SDK - Receiver 'BoxSearchRequestBuilder' for class message is a forward declaration

분류에서Dev

calling method in template class in template member function of another class

분류에서Dev

Accessing derived class member from base class pointer

분류에서Dev

Add extra class on basis of if ... else statement

분류에서Dev

Segfault when using std::function class member with compiler optimizations

Related 관련 기사

  1. 1

    Class has no member "Class"

  2. 2

    "syntax error, unfinished class declaration"

  3. 3

    Lambda function as class member

  4. 4

    Member in child class a reference to parent member?

  5. 5

    Using getline with ifstream class member

  6. 6

    Issue with declaration of Map<String,Class<? extends Serializable>>

  7. 7

    Where is declaration of invoke method in Delegate class?

  8. 8

    Python: Hide member of base class in derived class

  9. 9

    Creating a class instance as a member of another class

  10. 10

    accessing the member of a class of pointer array of another class

  11. 11

    Passing a member function of a class to a parameter outside the class

  12. 12

    `In instantiation of [template class] [member] is protected [. . .] [public member] is inaccessible'

  13. 13

    jQuery if statement change div class to another not class

  14. 14

    Difference in Use statement outside class / inside class

  15. 15

    Is it possible to define a virtual static member on a delphi class?

  16. 16

    Call member function when class type is not known

  17. 17

    Serializable class with unserializable injected member in JAVA

  18. 18

    Cannot access private member declared in class

  19. 19

    Forcing initialization of static data member of template class

  20. 20

    C++ class member check if not a template

  21. 21

    Resolve ambiguousness of a base template class member

  22. 22

    my class does not have a member property

  23. 23

    What is the difference between private and private[Class] declaration in scala?

  24. 24

    Drools variable declaration in condition depending on class type using "not"

  25. 25

    Box iOS SDK - Receiver 'BoxSearchRequestBuilder' for class message is a forward declaration

  26. 26

    calling method in template class in template member function of another class

  27. 27

    Accessing derived class member from base class pointer

  28. 28

    Add extra class on basis of if ... else statement

  29. 29

    Segfault when using std::function class member with compiler optimizations

뜨겁다태그

보관