|
I'm trying to create a class that I don't want anyone to be able to create a handle to, aside from another specific class. In native c++, I could this by just declaring the creator class as a friend to the class I'm restricting creation for. However, in C++/CLI, it won't allow me to have friends for a managed type.
Does anyone know how I could get around this problem?
-Kevin
|
|
|
|
|
The absence of friend classes is a real problem in .NET, IMO. I'm not sure there's a way around it, if you want the actual class visible, but not the ability to create. Does your class derive from anything right now ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi! I'm learning about linked lists and have created the following class:
<br />
<br />
struct Node<br />
{<br />
int data;<br />
Node *next;<br />
Node *prev;<br />
};<br />
<br />
class BasicList<br />
{<br />
public:<br />
<br />
BasicList();
<br />
<br />
void Prepend(int n);
void Append(int n);
void InsertAfter(int key, int n);
void InsertBefore(int key, int n);
void Swap(int first, int second);
void Remove(int key);
<br />
<br />
void DisplayNodes() const;
bool IsEmpty() const;
int Maximum() const;
int Minimum() const;
int Occurances(int key) const;
int NumNodes() const;
<br />
<br />
Node *GetAddress(int n);
int *GetDataArray();
<br />
private:<br />
<br />
<br />
Node *head;
Node *tail;
};<br />
<br />
All the functions work wonderfully so far. I want to add a method that will sort the linked list data. I'm not really sure where to begin. I checked Wikipedia, and found the following URL which presents a MergeSort algorithm. I'm not sure if this is the best way. Any opinions?
http://en.wikipedia.org/wiki/Merge_sort
|
|
|
|
|
How can I clear screen screen in simple C languange , NOT in C++
system(cls") , or cls() or , clrscr() are not working
Regards.
|
|
|
|
|
This is the managed C++ forum. Managed C++ can NEVER be just C. This is the wrong place to ask this.
Define 'not working' when you ask this again in the right place.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello everybody,
We are planning to work on a project. The client side will be created with VB.net. This VB.net will call the backend of c code. I did the similar thing with php to call the backend of c code. The bridge between the php and c code was created with php extension for wrapping c code. Could you give a suggestion what kind of bridge will be created between VB.net and c code?
Thank you very much for your any suggestion
Jane
|
|
|
|
|
JaneQuestion wrote: what kind of bridge will be created between VB.net and c code?
VC++ has "managed extensions". You can create "mixed mode" projects. What you want is a mixed mode Class Library. The .NET classes that you author in this library will then call into the "native" C code. When authoring such code you will be handling the marshalling of data from native memory into managed memory and managed memory into native memory where ever it is required.
The .NET classes you author can be used from any .NET compiler including VB.NET.
JaneQuestion wrote: The client side will be created with VB.net
C# would be a better choice.
|
|
|
|
|
Thank you very much for your information. Do you know where I can find this kinf of sample code?
Jane
|
|
|
|
|
Thank you very much for your reply. But our project requires that the client side will be implemented in VB.NET, the backend was implemented in C, which will talk with hardware device. I need to make a bridge between VB.NET and C. Any good suggestion?
Thanks a lot in advance
Jane
|
|
|
|
|
JaneQuestion wrote: Any good suggestion?
I don't understand, I gave you a suggestion. Why do you ask for one?
|
|
|
|
|
Hello,
I'm a student working towards a BS in CS. I use Visual Studio C++ as my IDE.
I go through a lot of paper writing out solutions to problems. I've found that this greatly helps me when designing my code and it's something I've found suggested many many times.
Last year, I was playing around with Visual Studio 2005 Beta and found something called "Whitehorse." It was excellent! It allowed me to create diagrams and drawings of my code. It actually would generate drawing and diagrams from my code and modify my code to match a diagram if I asked it to.
I haven't found similiar functionality in Visual C++ 2005 Express. I'm (very sadly) assuming that it's not there.
I'm REALLY hoping that someone may have an alternative solution for something that works well, and is free. I REALLY appreciate any suggestions.
Thank You,
Nathan Farrar
http://yogensha.com/
|
|
|
|
|
How does it generate the list?
If I plug my stand alone laptop into a clients network and open NN it will list the domains on the network, it won't let me browse them as I'm not allowed but it does list then...
How does it do this, and how can i replicate the effect...?
I never expected a simple browser component to provide such a headache...
Does anyone know how to achieve this...
Please please,
Rob.
|
|
|
|
|
Hi,
I've written a library in VC++.NET2003 with 1 exposed class and 2 Inner classes:
Inner Class1:
WinInet Wrapper used in making HTTP requests through WinInet APIs (InternetOpenW, InternetOpenUrlW, InternetReadFile).
Inner Class2:
MSHTML wrapper used in extracting text/links out of HTML. All the interaction with the MSHTML is done through mshtml.h
Exposed Class:
Exposes various functions to make HTTP requests, transform the HTML data etc.
Above library is used in a C# GUI application. This app spawns upto 50 threads and in each of these threads, C++ library will be called.
I'm very much new to C++, but after going through various articles and source code examples, I've written the library and it is working fine if used sporadically. But in the Multithreading scenario, memory is shooting up and CPU usage was also very high. Read somewhere to rename/delete the below given Reg key:
HKCU\Software\Microsft\CurrentVersion\InternetSettings\ZoneMap
I'd changed the Zonemap name to Zonemap1. Since then the CPU usage has come down but the memory problem remains.
Prior to writing the C++ library, used MSXML3 (xmlHTTP) and mshtml.dll in C# itself. But Microsft specifically says not to use MSXML in .NET. Though MSXML was quite fast, it also consumed tonnes of memory.
Now I'm at a crossroads and not sure which one is causing the problem:
WinInet
MSHTML.
Using the above in multiple threads.
Could some one tell me what is causing the problem or point out to links\articles?
Thanks & Warm Regards,
Keshav
|
|
|
|
|
keshavcn wrote: This app spawns upto 50 threads
keshavcn wrote: But in the Multithreading scenario, memory is shooting up
I would "guess", which is not the right way to optimize (use a profiler), that MSHTML is "a" source of significant memory usage.
MSHTML is parsing the HTML and creating an Element structure, probably a tree or something. That is going to take some memory. If you load 50 of them it will take 50 times the memory right?
keshavcn wrote: MSHTML wrapper used in extracting text/links out of HTML
So if you replaced MSHTML with a parser that finds the "text/links" without loading the entire HTML document into memory then that should reduce memory usage. Again without using a profiler this is just a "guess".
|
|
|
|
|
Hello:
I want to change wma to wav,I find it difficult.
Who know the source code about it, pls tell me.
Thanks
|
|
|
|
|
In C# I could remove security check on an C DLL call by tagging my function as follow:
[System::Security::SuppressUnmanagedCodeSecurityAttribute]
[DllImport("SomeDll.dll")]
static extern void SomeMethod();
In Managed C++ I don't declare the function I just #include the headers.
How could I avoid security stack walk?
|
|
|
|
|
I have a managed C++ API which calls extensively into native API.
I would like to remove the security walk above!!
in C# I could tag my declaration like that:
[System::Security::SuppressUnmanagedCodeSecurityAttribute]
extern static void SomeCFunction();
but in managed C++ I don't declare the function, I just import the header
and call the function.
how do I avoid stack walk?
|
|
|
|
|
I am getting a large number of errors with this function in my program:
private: void downloading(System::String ^location, System::String ^file){<br />
System::Net::WebClient::DownloadFile(location,file);<br />
}
When I try to compile the program I get c2352 errors (illegal call of non-static member function). I think there is something small that I am missing but I am not sure what it is. I have tried many different versions of this code, and placing it in different parts of the code, etc. Any help would be greatly appreciated.
Thanks.
p.s. I am working on a windows forms application with vs2005 c++ express.
|
|
|
|
|
Bob X wrote: illegal call of non-static member function
DownloadFile is a non-static function which you are calling statically so... you can't do that.
|
|
|
|
|
led mike wrote: which you are calling statically
Would you please be able to point out how to call it non-statically. I have tried many different ways, all of which have not worked.
Thanks
|
|
|
|
|
Bob X wrote: Would you please be able to point out how to call it non-statically.
Certainly, they hide those examples in the documentation[^]
|
|
|
|
|
|
Hi,
I am a silent member of the group. I have a question and I would like to know the logic behind the development of the program...
The question is as follows:
There are 4 cowboys each wearing a hat which can be of two colours: Green and red. There is a sheriff whose pocket is full of coins. When the sheriff takes out a coin from his pocket, the cowboys changed their hat from one colour to another.
The problem is to write a c++ or a c code to find those cowboys who are wearing the same colour hat at any moment...
If someone can develop the program , I would be grateful...
shekkk.
|
|
|
|
|
shekkk wrote: The problem is to write a c++ or a c code to find those cowboys who are wearing the same colour hat at any moment...
Number of the coin out of the pocket % 2;
if(result == 0)
wearing origional hats
else
wearing other colour hats
|
|
|
|
|
I am surprised that you don't mind doing someone else's homework ?
|
|
|
|