Not a C++ coder needing C++ help
-
I need to put together a sample project that does one simple(?) task in C++ Inherit System.Exception override Message return my own Message What I have so far...help is greatly appreciated.
// TestCPlus.h #pragma once using namespace System; using namespace System::Diagnostics; namespace TestCPlus { class MyException : public System::Exception { public: int rCode; char* blah; // probably wrong type definition for string char* Message : System::Exception::Message { return blah; }; }; }
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't. -
I need to put together a sample project that does one simple(?) task in C++ Inherit System.Exception override Message return my own Message What I have so far...help is greatly appreciated.
// TestCPlus.h #pragma once using namespace System; using namespace System::Diagnostics; namespace TestCPlus { class MyException : public System::Exception { public: int rCode; char* blah; // probably wrong type definition for string char* Message : System::Exception::Message { return blah; }; }; }
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.Hope this will help, Serge #include "stdafx.h" #using using namespace System; __gc class MyException : public System::Exception { public: __property virtual String* get_Message() {return "Hello, World!";} }; int main() { try { throw new MyException; } catch (MyException *e) { Console::WriteLine(e->Message); } return 0; }
-
Hope this will help, Serge #include "stdafx.h" #using using namespace System; __gc class MyException : public System::Exception { public: __property virtual String* get_Message() {return "Hello, World!";} }; int main() { try { throw new MyException; } catch (MyException *e) { Console::WriteLine(e->Message); } return 0; }
Serge, Thank you very much. So here is the big question: Is there a way in C++ to append comments to methods and properties as there is in C#. I know that C++.net does not recognize the triple-slash, but I also saw something about Output Browser Information and was wondering if that was the mechanism for exposing method comments???!! Michael There are 10 kinds of people in the world.
Those that read binary...
...and those who don't. -
Serge, Thank you very much. So here is the big question: Is there a way in C++ to append comments to methods and properties as there is in C#. I know that C++.net does not recognize the triple-slash, but I also saw something about Output Browser Information and was wondering if that was the mechanism for exposing method comments???!! Michael There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.Michael, MSDN states that “Visual C++ provides limited support for XML documentation comments”. I do not know what they mean by that (what is supported and what is not), but as per the .NET 2003, even if I want to attach a simple summary to a class, like this: /// /// This is my Visual C++ class /// class MyClass { }; Visual C++ would generate an empty Comment Web Page (via the “Tools | Build Comment Web Pages…” option). And the Visual C++ compiler does not support the /doc compiler option as the C# compiler does. May be other people have something to say on this? Serge