|
Base class List(T) already has a default indexed property. You need to define your own on your class and mark it as new .
property T default [int]
{
virtual T get(int index) new
{
}
virtual void set(int index, T value) new
{
}
}
Best wishes,
Navaneeth
|
|
|
|
|
|
posting the same question multiple times is against the site's rules, and will keep people from answering at all.
Did you read the forum guidelines?
|
|
|
|
|
Need to pass private member of a Class as a argument to function of another class and get modified there and Class A will again user the modifed value of x there after..
int .Net Managed C++
class A
{
private :
int ^x;
...
B ^ ojbB;
ojbB->TheFunctionneedsPrivateObjectof_A( int &x)
}
class B
{
public TheFunctionneedsPrivateObjectof_A(int ^x)
{
Modify x here
}
}
|
|
|
|
|
You could declare a property p_x in class A. Class B would then use p_x to get the value of x,then it can operate on the value at will, and finally use p_x place the result back into x for class A to carry on with.
Ger
|
|
|
|
|
If x is already a reference to an object (why int ^ ?) then all you should need is:
ojbB->TheFunctionneedsPrivateObjectof_A(x);
which will pass x as a reference to the object, thus allowing the called function to access its member variables.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hmm. That would cause an unnecessary strong dependency. And the member was private.
|
|
|
|
|
He/she asked how to do it, not whether it was a good thing.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hm, it depends on what are you are trying to accomplish. I assume you are dealing with CLR types in your example. In this case you are missing the ref keyword. If A and B are meant to be native C++ classes the code as you have posted it is wrong and would never compile since you cannot hold a handle to a managed type in an instance of a native class without resorting to gcroot . That said, technically, you can of course pass a handle or tracking reference to a CLR object like this:
public ref class A {
YourComplexObject^ mHandleToYourComplexObject;
B^ mHandleToB;
public void PassYourComplexObject() {
mHandleToB->TakeComplexObject(mHandleToYourComplexObject);
}
};
public ref class B {
public void TakeComplexObject(YourComplexObject^ pHandleToYourComplexObject) {
}
};
EDIT: Corrected PassYourComplexObject
modified on Friday, January 7, 2011 6:13 AM
|
|
|
|
|
with the example below you should be set
Also works for other ref classes not only for primitves as int.
ref class A
{
private :
int x;
...
void foo()
{
B ^ ojbB;
x = 1;
ojbB->Increment(x);
}
}
ref class B
{
public:
void Increment(int %x)
{
x++;
}
}
Hope, I could help...
|
|
|
|
|
How to get the delagate value via property
property MyCallback^ CallBack1
{
MyCallback^ get {return m_pCallBack; }
}
Private MyCallback^ m_pCallBack;
Thanks
|
|
|
|
|
Here's one way:
using namespace System;
public delegate bool MyCallbackDelegate(void);
public ref class Test
{
private:
MyCallbackDelegate^ m_pCallBack;
bool doIt(void)
{
Console::WriteLine("Do It Called");
return true;
}
public:
Test()
{
m_pCallBack = gcnew MyCallbackDelegate( this, &Test::doIt );
}
property MyCallbackDelegate^ CallBack1
{
MyCallbackDelegate^ get() { return m_pCallBack; }
}
};
int main(array<System::String ^> ^args)
{
Test^ t = gcnew Test();
MyCallbackDelegate^ d = t->CallBack1;
d();
return 0;
}
John
|
|
|
|
|
Getting warring
warning C4677: 'Invoke': signature of non-private member contains assembly private type.. at
public delegate bool MyCallBac..
But I need the property to be public..
|
|
|
|
|
I don't see any warnings with the code I posted so you have something different. I'd need to see more code to help diagnose the problem.
The property and delegate are public in my example.
John
|
|
|
|
|
XmlSerializer^ serializer = gcnew XmlSerializer(typeid);
stream = gcnew FileStream(filePath, FileMode::Open, FileAccess::Read, FileShare::ReadWrite);
try
{
Object^ temp = serializer->Deserialize(stream);
A first chance exception of type 'System.Runtime.InteropServices.SEHException' occurred in tcs077j2
Additional information: External component has thrown an exception.
Please advice.. Thanks
|
|
|
|
|
As a suggestion you should create a test app that does a very simple deserialization.
Then run with Purify.
If it still crashes then it would suggest that there is a bug in Purify.
If it doesn't then add attributes one at a time into the test object, testing each one, to bring it up to match the object that causes the crash in your app.
If you replicate the full object without a crash then if it was me I would suspect some bug elsewhere in your code, specifically unmanaged code. Bugs in unmanaged code can cause failures long after the actual code ran.
|
|
|
|
|
Usering a Test App I was able to deserialize complete XML file. But Can you please suggest the tips to find the issue.
When I run without purify every thing is fine
But when I rung with purify the issue comes. May be purify is sensiable enough to catch the issue, but I want to find the exact location of the issue. Please advice
thanks in advance
|
|
|
|
|
ptr_Electron wrote: Usering a Test App I was able to deserialize complete XML file.
Presumably you mean with Purify running.
If so then as I suggested I would then suspect and first look to any unmanaged code in the application. If you do not have unmanaged code (nor 3rd party libraries that use it) then obviously that is not a problem.
If you don't know if you have any then I can't help you with that. And if you have it but don't know how to find the problem then the only sure way is via inspection. However streneous testing can help.
|
|
|
|
|
Yes, correct.. running the test application with purify with the same xml file is very well running fine.
But when I run my application with purify with the same xml file then it crashes at Deserialize method.
So the Unmanaged code before calling the Deserialize method should have some issue. I have that unmanaged code
So I believe this should be mostly some kind of memory overwrite issue ?
Do you think windgb or App verifier should give some clue.
Thanks for your time
|
|
|
|
|
ptr_Electron wrote: So I believe this should be mostly some kind of memory overwrite issue ?
It is a 'pointer' problem. There are many ways in which a pointer can be misused.
An overwrite is one way. An underwrite is another. A miscast is another. Misusing sizes is another. Etc.
There are C++ (straight C++ apps, not managed) tools which exist to determine in problems C++ code. It requires that one excercise the code very well.
Inspection is probably still the only sure option - at least as sure as it can be.
|
|
|
|
|
i want to show count down of seconds, as the user enters the answer the countdown should have stoped....just like a quiz program, i want to do it in VC++6
|
|
|
|
|
Create a dialog(whatever) , use function SetTimer to set the timer.
(like SetTimer( your_window,QUIZ_TIMER,1000,0); )
then handle WM_TIMER message . In mfc you can handle it by adding the ON_WM_TIMER macro in message map.
then in OnTimer callback check for your timer id then do whatever you need to display
void MyDialog::OnTimer( UINT id )
{
if( id == QUIZ_TIMER)
{
}
}
If u can Dream... U can do it
|
|
|
|
|
Try the TaskDialog or ProgressBar (or any other) controls from MSDN[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Callback is the delegate. I have a calculated string which give the function name and I want to pass this string to delegate. How can I achive this. Please advice
String FunctionName ="Myfunction"
String FunctionID="5679"
FunctionName = FunctionName + "_" +FunctionID
cbk->m_pCallBack = gcnew Callback(this, FunctionName);
Please advice
|
|
|
|
|
Please don't cross-post, its considered rude. Choose a forum and stick with it, and you're more likely to get a response.
If you know the type of the object, Reflection can be used to get hold of a function by it's name. Take a look at the Type.GetMethod function.
|
|
|
|