4 ms·
No, what he means is that something like foo * bar; Can mean two different things. If foo is a defined type (typedef int foo, for example) then that decla
by koenigdavidmj 16y ago
No, what he means is that something like
foo * bar;
Can mean two different things. If foo is a defined type (typedef int foo, for example) then that declares a variable bar of type foo. If it is not, then we're multiplying variables foo and bar.
- j_baker 16y agoYes, that is context-sensitive, but it's pretty tame. First of all, if I look at that, I can tell it's probably a pointer. After all, it doesn't make much sense to multiply two variables and then not do anything with the result, does it? On the other hand, it can mean a variety of things in C++. Are we multiplying numbers? Is foo or bar an instance of a class that has the * operator overridden? Is there a global overload of the * operator? Are we declaring a pointer?
- kenjackson 16y agoBut in a well-written program the use of overrides would make sense. Just as much as this function: ExitProgram(); should be clear in the context of a program. Now it's possible that this function actually creates a new process that then plays tic-tac-toe. But in a decent program, it will do its best to be consistent with what you expect. Likewise, if I see A * B, I expect that we're multiplying A and B. What does multiplication mean? Depends on the application, but I expect it to make sense. And with a decent IDE you should easily be able to get the def for the '*', just like you'd get the def for any other function. The problem isn't in the C++ language, but rather the C expectation that many developers have.
- deleted 16y ago[deleted]