Relative Content

Tag Archive for c++language-lawyer

What is a target scope of a static member definition?

int x = 42; struct A { static int x; // 1 }; int A::x = x; // 2 Why at 2 the redeclaration of x inhabits a class scope? Where is a locus of some declaration – only at the first declaration (1) or every redeclaration has its own locus (1 and 2)? c++ […]

How are we able to default construct object without a default constructor

I learnt that when have a user provided constructor in a class then the compiler will not implicitly generate a default constructor. Then I wrote the following code C d{}; in particular that I expected to fail(give error) because as per my understanding there is no default constructor for this class.

Are pointers of different types compatible?

I’m trying to determine if two structs are compatible. In my case, it’s not clear to me if pointers of different types are considered compatible. In the following example, are structs t1 and t2 compatible?