My interview question:
If you have a global variable and put the name "static" in front of it, what does this change?
I said nothing. I guess I missed the point of this question?
So it makes it local to the file. So this was such a big question to ask because if you don't know that, you obviously don't know how to program. God damn.
Quote:Original post by dpadam450More exactly, it makes it local to the translation unit. (A static global declared in a header file is most certainly not just local to the header file.)
So it makes it local to the file.
Quote:So this was such a big question to ask because if you don't know that, you obviously don't know how to program. God damn.If you don't know that, you obviously haven't spent much time getting to know your language of choice, or interacting with others' code in that language.
It may or may not be a bogus question depending on various factors. If you stated on your resume that you were highly proficient with C or C++ then yeah, getting that answer wrong would look a little bad because it would make it seem like you weren't that proficient. If it was just one small component of the interview out of many similar language construct questions it probably wasn't that important. Other concerns are how many people are applying for the position. If there are a LOT of people trying to get this job then, all other things being equal, why not drop the candidate that can't answer the question correctly? This isn't exactly highly obscure trivia. A lot of programs, particuarly some C programs I've worked with, use global static variables. I don't like 'em, but they're there.
It could just be a crap interview though.
It could just be a crap interview though.
"or interacting with others' code in that language."
Well I've only worked on games at school and I've never had anyone do this or have any teacher mention it. I've never professionally done anything so that would be the reasoning. It still kinda sounds sloppy, being that it is still global. I dont know.
Either way, I looked it up after the guy above sent me a link. 5 seconds I know what it means. Really this is a big deal?
Well I've only worked on games at school and I've never had anyone do this or have any teacher mention it. I've never professionally done anything so that would be the reasoning. It still kinda sounds sloppy, being that it is still global. I dont know.
Either way, I looked it up after the guy above sent me a link. 5 seconds I know what it means. Really this is a big deal?
Quote:Original post by dpadam450
Either way, I looked it up after the guy above sent me a link. 5 seconds I know what it means. Really this is a big deal?
If you plan on using C or C++ for anything non-trivial, you better know your statics. They are both languages where something can compile, but then fail miserably during linking.
Personally, I avoid static context like plague, but that is not a luxury one can afford in any or at least most real world projects.
The basics of C++ are here. It would be prudent to understand each and every point listed there.
Quote:Original post by dpadam450They don't care about static in particular. They asked you the question to gauge whether you really knew a lot about the language, or whether you only had a limited, working knowledge. Apparently they judged correctly. But perhaps if you whine about it, it'll make things better!
Either way, I looked it up after the guy above sent me a link. 5 seconds I know what it means. Really this is a big deal?
Quote:Original post by dpadam450
Either way, I looked it up after the guy above sent me a link. 5 seconds I know what it means. Really this is a big deal?
As an interviewer I don't care about you looking it up. I care that you GUESSED the answer. You should have said: "I don't know" if you had been talking to me.
I don't want people guessing, I want people that know what they know and what they don't know. Never guess, be honest about knowledge. And when you are afraid of answering "I don't know" state it differently: "I am not entirely sure, I would have to look it up. I never used it as I never use global or static variables." (if that is true)
Well my answer actually was that it would be the same. It is all just compiler time and that a static variable is really just a global variable at run-time, it stays in memory at the exact same location and not on the stack, so declaring a global variable to be "static" (not on the stack) -> that is what a global variable is already.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement