when i use this code
using
namespace::System.Windows;void
main(){
public:static
MessageBoxResult Show (String^
"hi!")
}
it always has an error (it says i need a semicolon before public).. why is this
when i use this code
using
namespace::System.Windows;void
main(){
public:static
MessageBoxResult Show (String^
"hi!")
}
it always has an error (it says i need a semicolon before public).. why is this
messagebox.show (string) method
natchURL
You made me smile!
I think it would be good to back up a little and compile some already-worked examples to see how it is done. You can start with the example at Help | Search "Creating a Simple Windows Form"
- Dennis
So you are perhaps used to programming in Java or C#, is that it
main() is not a class definition, it is a simple function declaration. Think of it as a free-standing method (the main method of the entire program that you are compiling).
main() itself is automatically public (external) and static (in the class loading sense). The public keyword is not usable inside a method (that is, a function body). You also don't need to say static on an internal declaration. It isn't helpful here.
If your program compiles with those changes (and it shouldn't), you may find that it doesn't do anything. There's much more to figure out. Look up "message boxes" in the VC++ 2005 Help | Index.
- Dennis
Dave Smalley
I was thinking that I was a little cavalier. The "Creating a Simple Windows Form" is a little mysterious. Here is a simple program a bit like yours that compiles. It is a command line program, so you will see a console window, but the message box does appear. After this, you might try the Windows Form. Or more simple examples.
MazterDeath
so the code will be
void main();
{
Messagebox stuff
}
hope that helps