#Function call vs object construction
15 messages · Page 1 of 1 (latest)
When your question is answered use !solved or the button below to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

depends on the whole line
As in if it has 'new' before it?
not even new is needed
struct X{
int i,j;
X(int i, int j) : i(i), j(j){}
};
int main(){
X x = X(3,4);
return x.i;
}
But yeah either way just avoid such scenarios and you'll be fine. With proper naming it shouldn't happen
Right in this case it's only aware of a type named X and not a top level function of the same name so the resolution is easy
If there's a naming conflict, the compiler might be able to figure it out from context or you'll just get an ambiguity error
Use nouns for types and verbs for functions and you'll be fine
There's nothing to avoid here IMO, X x; is a common pattern
world war 4 will happen
it'll show an error for u
bc naming conflict