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.
Where did you see that a variable declared twice?!
He had ClassName classVariable on both line 1 and 3.
only if they are small enough to fit on the stack.
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.
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.
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.
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.
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
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.
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?
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.
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! ;)