Third interview - programming test

Pages: 123
however in C# you would have an error as well for declaring the same variable name twice. And C# runs very differently for that. (value type go on the stack, reference type go on the heap. classes in C# are only ever ref type. while structs are only ever value type.)

when you do:
MyClass myClass;
you put it on the stack which will self-destruct once it goes out of scope.

when you do:
MyClass myClass = new MyClass;
you put it on the heap. where you have to destroy the object yourself with delete.

stack is small, heap is large. You should put big objects on the heap.
Last edited on
@Oria (138)
however in C# you would have an error as well for declaring the same variable name twice


Where did you see that a variable declared twice?!
ok in C++, is the only appropriate way to create objects:
 
className classVariable

?
Where did you see that a variable declared twice?!

He had ClassName classVariable on both line 1 and 3.

@rcast
only if they are small enough to fit on the stack.

edit:
for example, if you have a game object called Engine. which will be big and run for the entire game session. You would definitely put it on the heap and manually called the destructor when the game is over.
Last edited on
I capisci
if you have a game object called Engine. which will be big and run for the entire game session. You would definitely put it on the heap and manually called the destructor when the game is over.

It doesn't make sense. If it needs to be gone when game session ends, the way to express it is to declare it in the scope of this game_session() function. If it needs to be gone when the program ends, the way to express it is to make it static.
I was just giving a random exemple for rcast to understand better.

edit:
also, because I come from C# where every class is an object created on the heap and because i have not learned about smart pointers yet in C++. So far I've been relying on new/delete for larger object.

Now I am a little confused about the game_session() function thing. because I would generally place most if not all, my function within classes and I would not put an object of that size onto the stack.
Last edited on
@Oria
Where did you see that a variable declared twice?!

He had ClassName classVariable on both line 1 and 3.


He had no two declarations of classVariable. You should learn to read what others write.
He had no two declarations of classVariable. You should learn to read what others write.

Somehow I feel I could say the same about you?

And why does this matter so much to you? why so argumentative to a point where you feel like you need to tell me how to read? Most of the time I am on this forum is during weekdays, when I am at the office, where I could of easily been distracted and miss something. In the end I am just trying to help rcast, while your picking fights with other people trying to help.
Last edited on
I declared the class variable once, in each of the two different scenarios.
Last edited on
@Oria
And why does this matter so much to you?


You do false resumes. It is not a help. You only confuse people with such false statements.
Any good free tutorials on nodes and linked lists? I draw a blank here, and I cannot afford a book to help me learn C++ :(
Last edited on
You only confuse people with such false statements.

Even if that's not what he meant to portrait in his example. Does not mean my statement is false. You cannot declare the same variable twice in C#. Might not applied to what rcast meant, but its not a false statement. But hey, thanks for the tip, since I guess that's how you like to be helpful :p

@rcast:
For free tutorials and articles other then this website. You can try:
http://www.codeproject.com
I've found some great articles on there in the past.

LOL, oria. I tried doing

int crash[1000000][1000000];

but my compiler wouldn't let me!
closed account (3qX21hU5)
Any good free tutorials on nodes and linked lists? I draw a blank here, and I cannot afford a book to help me learn C++ :(


Or you can try checking a local library depending on where you live they might have some good books that you can checkout for free.
Well my interview is tomorrow - time to put up or shut up. I'm hoping the hardest part will be waking up at 7am, but somehow I'm thinking this isn't going to be the case. I need to be able to work with a proprietary database software. I already know relational databases and SQL query pretty well. I think if I can show them I know databases in general, they will teach me.

Anybody have some good exercises with classes I can work on?
Last edited on
closed account (3qX21hU5)
Ohh come on I wake up at 5:30 am everyday to go to work ;p. I wish I could sleep in till 7am.

Anyways good luck with your interview and I'm sure you will ace it.
Well I'm back from the 3rd interview, it was an actual programming test with paper and pencil. 30 Minutes for 21 questions. Basically the test introduced you to a random language and each page explained one or two new concepts about the language and showed you syntax and asked you a question. Each subsequent page added more knowledge and concepts and tested you on all of the new concepts and old concepts and it just kept building on itself. All in all, I think I had to have gotten at worst a B, but I'm pretty confident I got an A. He had a important call so he thanked me for coming down and told me he'd be in touch.

I hope I got it!
If you don't mind me asking, what were those random languages? or were they in-house languages?
Oria *Language not languages

No it was not specified. Maybe one of you know. The or || operator was ! on the test, and the % modulo operator was #, the NOT was an apostrophe on the test, etc etc, it was all something I wasn't familiar with but i still aced it. I think I got my first programming gig! ;)
Last edited on
Pages: 123