I can do this
extern int i;
extern int i;
But I can't do the same with a class
class A {
..
}
class A {
..
}
While in both cases no memory is being allocated.
Example - Declaring multiple variables in a statementIf your variables are the same type, you can define multiple variables in one declaration statement. For example: int age, reach; In this example, two variables called age and reach would be defined as integers.
Declaring multiple variables in a single declaration could cause confusion about the types of variables and their initial values. In particular, do not declare any of the following in a single declaration: Variables of different types.
E2238 Multiple declaration for 'identifier' (C++)A function declared in two different ways. A label repeated in the same function. Some declaration repeated, other than an extern function or a simple variable.
There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (§4.2) and reference values (§4.3).
The following are declarations:
extern int i;
class A;
And the next two are definitions:
int i;
class A { ... };
The rules are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With