Friday, November 29, 2013

Using the same identifier for a Type and a Class: What is the semantic effect of that syntax?

"In the file Order.cs I found an unusual construct"


There's absolutely nothing unusual about that construct.


"Notice how the identifier Customer is used with 2 different purposes. IIRC, neither C++ nor Java allows such confusing usage."


I don't know about Java but C++ certainly allow something like that:



class foo {
};

class bar {
foo foo;
};

"Does that incantation have a special meaning and consequences?"


None at all.


"ps: I am not even sure whether my subject line is correct - Feel free to correct me."


Type and class are pretty much the same thing. You probably want to say "type and a property" or "class and a property".


No comments:

Post a Comment