|
Here's a simple example:
#using <mscorlib.dll><br />
using namespace System;<br />
public __delegate Int32 FactorialCallback(Int32,Int32*);<br />
public __gc class Factorial{<br />
public:<br />
FactorialCallback *fc;<br />
Factorial(){<br />
this->fc=new FactorialCallback(this, GetFactorial);<br />
}<br />
Int32 GetFactorial(Int32 iSeed, Int32 *iNumberOfCircles){<br />
(*iNumberOfCircles)++;<br />
return (iSeed==0)?1:(GetFactorial(iSeed-1,iNumberOfCircles)*iSeed);<br />
}<br />
Void FactorialComplete(IAsyncResult *ar){<br />
Int32 iNumberOfCircles;<br />
Int32 iResult=this->fc->EndInvoke(&iNumberOfCircles,ar);<br />
Console::WriteLine(S"The result is {0}, nuber of circles is {1}",iResult.ToString(),(iNumberOfCircles-1).ToString());<br />
Console::Read();<br />
}<br />
};<br />
<br />
int _tmain()<br />
{<br />
Factorial *fact=new Factorial();<br />
Int32 dummy=0;<br />
AsyncCallback *ac=new AsyncCallback(fact,&Factorial::FactorialComplete);<br />
fact->fc->BeginInvoke(5,&dummy,ac,NULL);<br />
Console::WriteLine(S"Main complete");<br />
Console::Read();<br />
<br />
return 0;<br />
}
|
|
|
|
|
Hello,
I discovered Jay Nelson's article XML Commments for Managed C++ Applications (http://www.codeproject.com/dotnet/MCXDoc.asp) with great joy, as this is a pressing issue for me. However I have not been able to make the addin actually generate XML. There is no contact info for the author in the article or elsewhere that I can find. So...
Has anyone had success with this addin?
If the author is reading this thread, would he be willing to contact me?
Michael Kairys
SL Corporation
michael@sl.com
Michael Kairys
|
|
|
|
|
er anyone here knows how to translate java into C++?? really need help guyz...i'm workin on datastructure type classes like linkedlist,linkedstack and linkeddeque and soon, i'll be workin on hashing tables... plz..plz...plz..plz.. any help would be appreciated...
|
|
|
|
|
Look at this wonderful tutorial: Java to C++ Tutorial.
I started in C/C++. Java and C# were much easier to learn because they got plenty of syntactic sugar from C++
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
so u know C++ very well man?? i'm workin on datastructures more specifically on linkedlist as deque/linkedlist/stack as linkedlist and closed hashing...and i'm having some trouble with translating these datastructs to C++...
|
|
|
|
|
|
woah! tnx man!
|
|
|
|
|
Hello everybody,
I want you to help me.
This is the question :
In dynamic polymorphism , if you had a pointer point to base class , it also can point to derived classes.
Example :
class Base {};
class Derived_1 : public Base {};
class Derived_2 : public Base {};
class Derived_3 : public Base {};
int main()
{
Base *BPtr;
int choice;
cout << "Which object do you need(1,2,or 3) ?";
cin >> choice;
switch(choice)
{
case 1: BPtr = new Derived_1(); break;
case 2: BPtr = new Derived_2(); break;
case 3: BPtr = new Derived_3(); break;
default:
cout << "Error number";
} // switch
} // main
*** In the exam above , I used switch...case control , so I want to ask you : by what way , you don't use switch...case in that exam ?????
I want to become a programmer.
|
|
|
|
|
The key point in the code was not focused on switch but polymorphism. You should have a look at the downcasts, upcasts, and the usage about dynamic_cast<> in your textbooks.
If you insist to replace the switch in the code, try if - else.
Maxwell Chen
|
|
|
|
|
When I am writing a little endian 4 byte int for the integer value 10 it writes out 5 bytes: '0D 0A 00 00', which is an extra byte in the first position.
10 should be '0A 00 00' but no matter how I try to write it out it ends up with 0D (which is the value signed byte 13).
The program creating the file is a C program using the fwrite function:
int Total_Points_Qt;
fwrite(&Total_Points_Qt, 4, 1, File);
The value is in an integer. I have tried unsigned int as well and it does not make a difference.
The extra byte problem does not occur at the values 1-9 and goes away at 11 and does not reoccur again at any other integer value except 10.
Does anyone know why this happens?
Thanks,
Steven
|
|
|
|
|
How to get HDD fabric number in NET?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Sub : How to use Amazon Web Services..
Hi all...
Please let me know How to start with amazon web services..
I'm not finding any XML or REST Query format to send request to amazon..
I've purchased Seller account but How to use that to upload Items..I don't know...
Please help me getting start..
I hope some one definatly know about this
e-mail if attachment at sumit_kapoor1980@hotmail.com
Thanks...
--Sumit Kapoor---
|
|
|
|
|
1) Wath is the corret way to use "put_Picture" for an Image control if I have the Path of the Picture to load (C++ MFC)?
2)How can I find the Ptah of the application that is running?
Thank's for all
Sorry for my English!!
Giulia
|
|
|
|
|
Hi,
My COM Component has a get method that takes pointer to the struct as input.
but when i use interop it is converted to the value not as pointer.
What happens to the pointer parameters during interop.
Blue Pill or Red Pill........??
|
|
|
|
|
Hi,
My COM (unmanaged) COmponent has a get method that returns the pointer to
the array of structures.
When using Interop Services ( i.e convertin to managed code by add refernce)
it shows that get method in managed code is simply returning a strucutre and
not a pointer to the array of structures.
How to solve this issue ?
I need the array of structures to be passed - does it needs to do anything
with boxing and unboxing.
Pls help.
Blue Pill or Red Pill........??
|
|
|
|
|
Hi,
Everytime some exception occurs i am unable to get the hold of exception,
how to debug the COM Interop scenario when the code and symbols are loacted
in Unmanaged Code and i am only using the Physiacl COM DLL.
Pls suggest.
Also Would WinDebugger help in this.?
Blue Pill or Red Pill........??
|
|
|
|
|
Hi,
i am using a COM component in the C# code , but when i retriive the
user-defined structure thru the COM Server and assign it to some struct it
fails.
Access Violation
What is the analogue of structure in C# and Also in managed C++.
Blue Pill or Red Pill........??
|
|
|
|
|
How can I consume a managed dll such as a dll that created by C# in unmanaged code like a MFC project?
|
|
|
|
|
#using <mscorlib.dll>
#using <system.drawing.dll>
using namespace System::Drawing;
...stuff...
you can replace drawing.dll with yours...
|
|
|
|
|
What is the Managed C++ !!!?
I want to know more about it and Do I must have VC++ .Net to use it or not??
Thanks
ahmed
|
|
|
|
|
How do i create a dll [roject in c++.net using the managed classes. I can do this in the standard c++ but I dont know how to do this with the new .NET framework for c++. Any help in how to do this or simply set up the project would be great -- Thanks in advance
|
|
|
|
|
How can i clear socket's incoming buffer??
|
|
|
|
|
by reading in it ...
TOXCCT >>> GEII power
|
|
|
|
|
I keep getting these errors and I can't figure out why the errors are there.
The line that is throwing these errors is this:
String * pstrDisplay;
BankAccount *pabnkAccounts __gc[];
int pintCurAccount;
pstrDisplay<<pabnkAccounts[pintCurAccount];
I am overloading the << operator like this:
// In class definition
static String *op_LeftShift( String *&, BankAccount * );
// Implementation
static String *op_LeftShift( String *&vstrOut, BankAccount *vbnkAccount )
{
vstrOut = String::Concat("Account Number: ",
vbnkAccount->GetAccountNumber().ToString()),
"\010\013");
return vstrOut;
}
Any help would be great.
|
|
|
|
|
cdmlb wrote:
Did you put
#include "iostream"
You still need to do this even if you are using MC++
I did this and there was no difference, I got the same error.
cdmlb wrote:
why not use
cout <<pabnkaccounts[pintcuraccount]<<endl;< i="">
I would do this but the BankAccount class is a managed class and I get errors when I try to use ostream in the overload it throws an error saying I can't use unmanaged code in a managed class.
cdmlb wrote:
Console.WriteLine(pabnkAccounts[pintCurAccount].ToString());
I would do something like this, unfortunately it is for school and I have to use the overload method.
I guess that I will have to keep messing around with it. I hope that I won’t have to rewrite the class as unmanaged, but I have to do what I have to do.
Thanks for your help anyway
|
|
|
|