|
|
Hoping somebody can help me with this. I looked for this issue coming up before, but I wasn't able to find anything. May be just my search skills...
Here's the question:
I have a class that generates events, using a custom event args class. That event args class contains a pointer to a large array. Something like this:
public ref struct MyEventArgs : EventArgs {
array<UInt16>^ imageData;
...
}
When this event gets activated, does the event args structure get cloned for each object instance that subscribes to the event, or is there a single instance of the event object with each event handler getting a managed pointer to the same object?
What I'm really getting to is whether the large array gets cloned for each event handler. I'm guessing no.
Many thanks in advance for any pointers (no pun intended...)
|
|
|
|
|
I just tried this out and each event handler received a reference to the same (one and only) MyEventArgs and thus the same array.
I changed some array values in the first event handler and subsequent handlers all saw the modified values in their arrays.
John
|
|
|
|
|
|
|
|
|
Sorry, but I couldn't understand what you want?
Could you explain more clearly?
|
|
|
|
|
Hey Guys,
I read this article regarding " Count from 1 to 1000 without using loops "
=============================================================================
#include <stdio.h>
#include <stdlib.h>
void main(int j) {
printf("%d\n", j);
(&main + (&exit - &main)*(j/1000))(j+1);
}
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.
=============================================================================
I tried to run this code and its perfectly working, but I am not getting how its works. How it calculates the end condition and all.
Please help me out.
Regards,
Amrit
|
|
|
|
|
The line
(&main + (&exit - &main)*(j/1000))(j+1);
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 .
|
|
|
|
|
Thanks Rechard for this clear explanation.
|
|
|
|
|
Very interesting!
I've never seen this code.
If I wanna plus all numbers between 1 to 1000 with out loops, how can I do it like above method?
Thank you for you advice!
|
|
|
|
|
Use a static variable and just add the value of j to it each time.
|
|
|
|
|
Thank you! 
|
|
|
|
|
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:
this->tabPage1->BackgroundImage = (safe_cast<system::drawing::image ^="">(resources->GetObject("tabPage1.BackgroundImage")));
The resX file is version 1.3 of the schema or so it says rather than the 2.0 that a newly created windows forms application has but seems OK otherwise.
<root>
modified 21-May-14 16:11pm.
|
|
|
|
|
|
Well it's not Managed C++/CLI that is for sure.
The makefile mentions gcc and you can find instructions on how to use gcc and a makefile here[^]
|
|
|
|
|
It looks very much like UNIX: all those shell scripts are a dead giveaway. So load it into your UNIX/Linux system, type 'make' and away you go.
|
|
|
|
|
(just realized this question is really old! oh well - might help someone)
I recently ran into a similar issue.
This worked for me:
- In Visual Studio create a C++ Win32 console application
- Add the .C files to the solution (add...existing item)
- Compile - default output is .exe
(The makefile seems to just compile the code - I think the .sh scripts might cleanup after the compiler. But, yeah, the makefile is designed to run in a linux/unix)
Erik Westermann
|
|
|
|
|
how to conver any base like binary to any base like hexadecimal and octal or others bases give me code
|
|
|
|
|
|
code to convert any base like binary to any base
|
|
|
|
|
Is this a question or a statement?
|
|
|
|
|
Hi Iam trying to convert my Digit To Words class from c# to VC++... And the following line I am facing trouble
String^ strNum;
String^ strNumDec;
String^ StrWord;
strNum = Convert::ToString(Num);
blah..blah...blah...
StrWord = ((double.Parse(strNum) == 1) ? " Rupee " : " Rupees ") + NumToWord((decimal)(double.Parse(strNum))) + ((double.Parse(strNumDec) > 0) ? (" and Paise" + cWord3((decimal)(double.Parse(strNumDec)))) : "");
Thanks for the helps
|
|
|
|
|
Paramu1973 wrote: trouble
And that trouble would be what exactly?
Paramu1973 wrote: blah..blah...blah...
is not valid C++ or C# code.
|
|
|
|