Premise
According to the Rule of Definition , as stated in C ++ 14 Standard , I can have a definition of the same class in each translation unit if I follow the rules in 3.2.6. This means that the following program will be legal:
class A {
int a;
static int b;
int foo();
int boo(){ return 42; };
};
class A {
int a;
static int b;
int foo();
int boo(){ return 42; };
};
If I try to define bor foo(), I will limit myself to just one definition in the whole program, which, it seems to me, is connected with the statement in 3.2.4:
Each program must contain exactly one definition of each non-built-in function or variable used by odr in this program; no diagnostics required.
For this reason, the following program is not correctly formed:
class A {
int a;
static int b;
int foo();
int boo(){ return 42; };
};
int A::b;
class A {
int a;
static int b;
int foo();
int boo(){ return 42; };
};
int A::b;
, foo() .
, , boo() ( ), 3.2.4 , , 3.2.6:
( 9), (7.2), (7.1.2), ( 14), (14.5.6), (14.5.1.3), - (14.5.1.1) (14.7, 14.5.5) , , .
, 3.2.6 , , ( boo()) .
a? , a ( , , ), , -, 3.2.4, 3.2.6. , , - ?
Edit
, , a , , , C + +14 , 3.2.2:
struct X {
int x;
static int y;
X(): x(0) { }
};
, , , .