The only other method to count 1 to 1000 is using recursion. According to C language, j has ‘1’as its value at the beginning. When 1 <= j < 1000, &main + (&exit - &main)*(j/1000) always evaluated to &main, which is the memory address of main. (&main)(j+1) is the next iteration we want to get, which would print ‘2’ on the screen, etc. The stop condition of this recursion is that When j hits 1000, &main + (&exit - &main)*(j/1000) evaluates to &exit, which will elegantly exit this process, and has the error code 1001 returned to the operating system.
is evaluated each time thus: &exit - &main is the offset from the start of main to the start of exit j/1000 will evaluate to zero for all vaules of j less than 1000
Multiplying those two values together gives zero if j is less than 1000.
Add that to &main (the address of main) and you get the same address, so main gets called with the parameter value j+1.
This continues until the value of j reaches 1000 at which time: j/1000 results in the value 1
That is multiplied by the offset of exit which returns that offset.
Add that value to main and the next call will go to exit rather than main.
I have an application developed in non-CLR C++ (unmanaged) in VS2003 (or earlier) but working with VS2005 after some converting. Note that I didn’t do that converting.
My employer decided to update the code to CLR VS2010 for easier maintenance. I am a C# programmer and haven’t done C++ for a while and not within VS so I’m not the most skilled in this task.
I’ve set it to CLR and corrected the errors and most of the warnings, but I’m having a problem with some image resources in the Form1.resX file (took me a while to even figure out that the resources were IN that .resx file I can see them in there and the Form [Design] editor can see the resource and paints the image as a background for its tab:
Create an STL vector of 10 integers and store initial values (0 to 9 is fine).
Use the std::random_shuffle algorithm to shuffle the list.
Print the list. (try to do this one with an std iterator)
Use the std::sort algorithm to sort the list.
Print the list again. (you can use for each instead of an iterator)
See if you can locate the documentation for random_shuffle and sort either in VS help or with Google. Once you leave this class, you will need to be able to find information like this on your own.
1. Did NOT create a folder for the solution
2. Project/solution named correctly
3. Correct comments at top
4. Consistent indentation
5. Good variable names
6. Overall neat organization
7. Comments in code explain what's being done
8. Correct division of code into .h and .cpp files
9. Use of #pragma once in .h files (or, #ifndef)
10. #include "stdafx.h" in cpp files (or, suppress pch)
Last Visit: 31-Dec-99 19:00 Last Update: 27-Jan-21 8:15