 |
|
|
I've tried to find a solution to this and I've had no luck.
For some reason, there seems to be an extra space at the bottom of my adrotator control. Border and padding are set to 0px, but it's still there. Has anyone else had this problem and how have you fixed it?
I know it seems like such a simple problem, but I have been through just about everything.
|
| Sign In·View Thread·PermaLink | 1.00/5 (7 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
class MyException : std::exception { ... }
try { throw MyException(); } catch(std::exception& ex) { }The exception is not going to be caught. Can you figure out why?
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
|
Different types? I see the inheritance, but possibly the catch doesn't.
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
sure. you can technically use either heap or stack based allocation, the difference being that the heap based approach requires you to clean up manually, and is a big potential for mem leaks. pretty much everyone uses the stack based approach.
¡El diablo está en mis pantalones! ¡Mire, mire!Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
That's the trick. In hindsight, the compiler is absolutely right.
I would like C++ compiler writers to issue a warning whenever private inheritance is used and the class itself is used for exceptions.
-- Kein Mitleid Für Die Mehrheit
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
That is exactly the purpose it is intended to serve. It's there to save some extra typing for programmers. Instead of aggregating another object as a member variable, it's merged together with the "this" object. I think the language should've required the use of a visibility modifier. That way it wouldn't have been such a potential source of errors.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
no idea. c# rotted my c++ brain too. not that i was really good at c++ though. i think that you can't do this in c++, but you can in c#?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
No, you can't make this mistake in C#, because you cannot specify whether the inheritance should be private or not. Inheritance is always public in C#.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I think I need to take 2 weeks off and go back to straight C++.
cheers, Chris Maunder CodeProject.com : C++ MVP
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
If parsing C++ wasn't so damn hard, I'd write a tool to find these things for me. During the build process at 2 am, the build server would send me an SMS for each find.
Do you know if Lint can find these kinds of things?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
C# rots your C++ brain C# rots your C++ brain
imagine what it does to non c++ brains (example: "The other day I saw the tooth fairy sodomizing easter bunny using a Dispose Pattern, SIDEWAYS!" )
led mike
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Yes. You definitely need less C#.
---- You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets .
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Shog9 wrote: You definitely need less C# I'm trying. I have started working with our C code base last year. It's a nightmare of course, unstructured, retarded spaghetti code. Unfortunately I still double duty in the wonderful new .NET world of our shop as well. I can't help but laughcry whenever I think about the dispose pattern.
Here, we give you ( developers that can't deal with memory management "pointers" ) this magical world of garbage collection to eliminate the burden of understanding how computers work. This new magical world provides more native access than Java and so make sure to take a look at the, *gulp* simple eh yeah eh simple Dispose Pattern to ensure you are allocating and releasing native resources correctly.
LMAO! Sure, they can't deal with pointers but they'll get this Dispose Pattern no problem! ROTF!  
led mike
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
C# hasn't rotted my brain, I saw that straight away. Maybe it's just you.
My current favourite word is: Nipple!-SK Genius Game Programming articles start - here[ ^]-
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
class MyException : public std::exception { public: const char* what() const { // overrides std::exception::what() return "my message"; } };
...
try { try { throw MyException(); } catch(std::exception& ex) { throw ex; } } catch(std::exception& ex) { std::cout << ex.what() << std::endl; }
What is the printout?
I found it by accident, as I was testing how some code I just wrote, works in extreme conditions. I was very surprised when I when I got the message "Unknown Exception" instead of "my message". Took me a couple of minutes in total astonishment to figure out what I was doing wrong.
The fix is very simple, and is the accurate way to do re-throws in C++. I think I missed this detail due to the fact that I've been doing some C# lately, where this pattern is the way to do it (excluding the exception-chaining pattern).
ps. This piece of code is a simplified version of my real code. I'm really not this stupid, as the code might indicate. ds.
[edit]I forgot the public inheritance modifier. It turned out that I forgot it in "real" code as well. See my part 2 just above this post. Switching between C# and C++ does stuff with your brain... At least mine. [/edit]
-- Kein Mitleid Für Die Mehrheit
modified on Tuesday, December 23, 2008 7:13 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
The reason is that C++ uses compile-time type information (the "static" type) while C# uses runtime type information since metadata is built-in to C#.
Hence the "throw ex" is actually throwing a std::exception& even though it "caught" a MyException&.
The simple fix here is probably to use "throw" instead of "throw ex". Using "throw ex" is bad form anyway when rethrowing a caught exception. The reason is that the exception's stack trace is rooted to the new location of the throw instead of the original location.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Not very similar, but it's involving dotnet & C++. Once, When I was starting to code mixed mode, I put the catch block like :
try { //Explosives } catch(System::Exception^ ex) { //Only managed clean up code. } catch(...) { //All unmanaged clean up code }
And wondered why my module was leaking memory in tons.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello! I'm very confused by your code. Your exception uses private std::exception as it's private parent. So MyException cannot be casted to std::exception. The code bellow works fine:
#include #include
namespace { class My_exception : public std::exception { public: virtual const char *what() const { return "My exception"; } }; }
int main(int argc, char *argv[]) { try { try { throw My_exception(); } catch (std::exception &exception) { throw; } } catch (std::exception &exception) { std::cout << exception.what() << std::endl; }
return 0; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |