|
Having got used to typing public static in C#, I tried writing the same in C++/CLI and sure enough, the compiler gave an error. Instead of changing it to
public:
static ...
I mistakenly modified it to static public instead. Surprisingly, it compiled fine. Examining the IL using Reflector showed that it had no effect, the method was private.
Is this a compiler bug or am I missing something?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i would go to the bug direction... what compiler did you use to try this ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
This was written in VC++ 2005 Express Edition, so it must be using the VC++ 8.0 compiler.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I know how to use winAPI to get the current drive contents with no problem but I am trying to write a shell program that will work on all operating systems.
Does anyone know how i can gather the drive contents of the current drive using just the standard C functions? No API and no MFC.
This is my first dos/shell command prompt program, please excuse my dumbness I am used to using API functions for everything.
Thanks for any suggestions or pointing me in the right direction.
|
|
|
|
|
You could use the CRT functions _findfirst and _findnext .
Regards,
Nish
|
|
|
|
|
Hmm.. I find your question interesting! I think you don't understand the meaning of API and/or the nature of C/C++. C/C++ is just a language. It is just a means of "using" an API. So to answer your question, there is no actual function that you could be sure would be supporting by any operating system in order to get the file structure. This is why for your case to be realistic you should start by making a list of the operating systems you would like your application to support. Only after that you can try to find a function that is supported on all of those systems (such as the _findfirst, _findnext functions the Nishant suggested). And for the operating systems that don't support those functions (in case ther will be any) you will have to provide the functions yourself.
|
|
|
|
|
I am very new to C++ and was just wondering how to create and write a csv file.
I am creating a simulation model for TB transmission and I have a list of people objects each with various attributes (age, gender, ID number, TBStatus etc) and i need to write the details of each person to file after each year of the simulation. The file would look like this:
ID#, age, sex, TBStatus etc...
1,52,0,0
2,3,0,1
3,21,1,2
Is this something to do with StreamWriter?
I would really appreciate some help with this.
Thanks
Georgie
|
|
|
|
|
If you're using managed C++, then yes, the StreamWriter is what you want. However, I'd recommend using ofstream instead/.
#include <fstream>
using std::ofstream;
ofstream str(filePath);
str << ID << ", " << age << ", "
etc.
Now, if these things are stored in a struct, you could look at my <a href="http://www.codeproject.com/vcpp/stl/iostreaminserters.asp" rel="nofollow">article</a>[<a href="http://www.codeproject.com/vcpp/stl/iostreaminserters.asp" target="_blank" rel="nofollow" title="New Window">^</a>] on how to stream custom types, then you could do it all in one line and code the commans into the inserter.
Christian Graus - Microsoft MVP - C++
-- modified at 17:00 Tuesday 15th November, 2005
|
|
|
|
|
Thanks so much for this.
I've got that all working so its very much appreciated.
Thanks
Georgie
|
|
|
|
|
There is a thread in windows form application.
I start several instances of this thread, and within its code it opens and closes from time to time a file on disk.
How to organize exclusive access to this file from several instances of a thread.
Thread:
...
...
open the same file //need to wait while this file is opened in
read data from it //another instance of this thread
write data to it
close file
...
...
...
..etc.. for file operation
...
...
9ine
|
|
|
|
|
Hello all,
I have a fully functional Visual C++ .NET console application that draws an ASCII character map at run-time in a DOS window. How can I start a window and draw the map real-time to that window as opposed to the DOS window? I have very little experience with Windows graphics so any advice would be greatly appreciated on how to start the window, draw to it, etc ...
By the way, the map I need to draw is simply a grid with different squares in the grid having different colors.
Thanks guys and girls.
|
|
|
|
|
As Windows is an event based system, all drawing happens in an event called OnPaint. If you're using C++/CLI ( managed C++ ), you can use the FillRectangle method of the graphics object to draw rectangles of different colors to the screen. If this is an MFC app, then the CDC class has similar methods, but there's more work involved, and more margin for error, in terms of resource leaks, etc.
If you clarify which one it is, I'd be glad to offer more advice if needed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello Christian,
Thanks for the quick reply. If you bare with me a little longer, we'd be able to figure this out. Much appreciated.
I have Visual Studio .NET and the program I wrote is simply an MS-DOS console project that I started as an "empty project" in VS.NET (C++ Projects). This is my second time using VS, I have been programming in VC6 until recently. The program runs fine as an .EXE under DOS. It draws a grid map that is updated in a seperate thread from a class that the main thread updates, in other words, the main thread creates the map class, updates its members, and a drawing thread automatically and simultaneously reads from the map class object and updates the graphic grid.
Now, I would like to move the graphics to a window as opposed to the DOS console. It seems from your reply that managed C++ is a better way to do that, and given that I know neither managed C++ graphics nor C++/MFC, might as well learn C++/CLI and use that.
This is what I'm trying to do. Any further reply is much much appreciated.
Thanks.
|
|
|
|
|
One more thing. My impression is that VS.NET allows you to program parts of an application in C++, part in VB, and so on. Would having VB do the drawing be easier than drawing with Managed C++? And if so, how can VB see the map's class and draw from it?
Thanks Christian (and all).
|
|
|
|
|
Big_Goose wrote: My impression is that VS.NET allows you to program parts of an application in C++, part in VB, and so on.
Yes, if you write part of it in dlls. There's rarely a good reason to do this, I've only just done it for the first time ever ( I wrote some really complex image processing code in C++, and now I have a C# app that wants to call it ).
Big_Goose wrote: Would having VB do the drawing be easier than drawing with Managed C++?
Yes.
Big_Goose wrote: And if so, how can VB see the map's class and draw from it?
You'd have to write a MC++ dll that exposes methods to return the data. I'd be surprised if it wouldn't be easier to rewrite it in VB or C#.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Big_Goose wrote: Now, I would like to move the graphics to a window as opposed to the DOS console.
OK - if you've used standard C++ so far, I'd be inclined to use MFC. An MFC app should be able to run the code you've already written, and then you can use the OnPaint method of the View class to draw your grid.
managed C++ is what I still call what is now C++/CLI, because I've never used either
If you already know C++, then MFC is probably the way to go. If you want to learn VB.NET or C#, then you need to turn your C++ code into a DLL which returns the data that needs to be rendered, or convert it to one of those languages.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is there any way to indiccate the insertion of duplicate key in STL map
babu.p
|
|
|
|
|
sarath_babu wrote: Is there any way to indiccate the insertion of duplicate key in STL map
You should ask this in the VC++ forum :-
VC++ forum[^]
|
|
|
|
|
Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays.
Uhm, if a guy cannot differentiate between MFC and C++/CLI, it's worth asking the question as to whether he's ready for either (MFC or C++/CLI).
-- modified at 12:51 Tuesday 15th November, 2005
|
|
|
|
|
The point is that most people don't know what C++/CLI *means*, they assume it's a general C++ forum, as opposed to the Visual C++ forum, which they assume is for MFC and other 'visual' stuff.
That's my observation, I learned ages ago to look in here every day, even though I know very little about CLI.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum?
I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum?
And rather than give out a terse (bordering on rude) reply like Nish's why not suggest an answer and if it genuinely belongs in another forum educate the user so?
Dissapointed I am
|
|
|
|
|
i do agree perfectly... so here comes my question :
why do you continue the thread instead of ignoring it ?
if you don't agree with some things, use the voting to express your feeling about that... (which is what i am going to do now )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Jeremy Thornton wrote: Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum?
Because the STL forum also caters to ATL and WTL, yet is a ghost town ? A lot of people do not know what CLI is, and assume that this forum is for 'standard C++' questions.
Jeremy Thornton wrote: I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum?
Who gives a toss what they would do ? People who are learning C++ are now required to understand it well enough to know which bits are STL before they are allowed to ask for help ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm sorry my views drove you to angry expletive I have tried to move what I thought was an important topic to the suggestions forum.
Christian Graus wrote: People who are learning C++ are now required to understand it well enough to know which bits are STL before they are allowed to ask for help ?
No that is the opposite of what I had intended to convey.
|
|
|
|