Search Results - CodeGuru Forums
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: laserlight

Page 1 of 80 1 2 3 4

Search: Search took 0.22 seconds.

  1. Replies
    11
    Views
    279

    Re: Bool type problem

    I think the onus is on you to support your claim. razzle mentioned clause 9.6, and it reads:

    Unless you show evidence to the contrary, it does seem that your claim that the standard guarantees...
  2. Re: I'd like to rewrite this comparison method.

    In that case I would suggest:

    bool Unit::operator==(const Unit& rhs) const
    {
    return id == rhs.id;
    }
    or if you have a public member function that provides access to id, overload operator==...
  3. Re: I'd like to rewrite this comparison method.

    Your code is not const-correct: the parameter to the original Equals member function should have been a pointer to const object since comparing for equality does not change the observable/logical...
  4. Re: I was constantly calling ostrstream? But private member access violation..

    I am not sure about "better", but it is standard, available via <sstream>. ostrstream is pre-standard (though a check shows that it is actually listed as deprecated, but it has been deprecated since...
  5. Re: Error - Call to non-static member function...

    It has to be a valid identifier. ____Date__ is a valid identifier, but it is reserved to the implementation (compiler/standard library) since names that begin with an underscore followed by another...
  6. Re: I was constantly calling ostrstream? But private member access violation..

    Is there a reason why you use the pre-standard ostrsream instead of std::ostringstream?
  7. Re: Error - Call to non-static member function...

    That is because getMonthName is yet another example of the const member function discrepancy that I mentioned in post #5.
  8. Re: Error - Call to non-static member function...

    A few other things to note:

    Change your header inclusion guard macro name too, e.g., use PaulP308_DATE_H instead of ____Date__.
    Do not use using directives like using namespace std; or using...
  9. Re: Error - Call to non-static member function...

    Ah. You forgot to prefix the member function definitions will the class name, e.g.,

    string getMonthName()
    {
    return monthName[ Date::getMonth() + 1 ];
    }
    should have been:

    string...
  10. Re: Error - Call to non-static member function...

    You might want to post the Date class definition. I'm assuming that these function definitions are within the Date class definition, but with what you posted we have to guess as to what really is a...
  11. Re: Qtcreator finds an error outside of program

    It compiles without even a warning for me, at least when I compile with respect to C++11 on g++ 4.8.2. You might want to post the error messages too.
  12. Replies
    7
    Views
    190

    Re: Using Comparables.

    In Java, the Object class has (and hence all classes have) an equals method that returns a boolean. The equivalent of this in idiomatic C++ is to overload operator== to return a bool. You could...
  13. Replies
    7
    Views
    190

    Re: Using Comparables.

    For C++-style, I would suggest:

    class Point
    {
    public:
    const int x;
    const int z;

    Point(int x, int z);
    };
  14. Re: Passing a class to a sprintf() and similar

    The argument to sprintf must match the corresponding format specification. Therefore, you should explicitly cast to char* even though you have provided an implicit conversion function to char*.
    ...
  15. Re: c++ 11 - can i override functions without re-declare them?

    I think you meant to write "you can NEVER define something without also declaring it" since all definitions are declarations, but not all declarations are definitions (e.g., forward declarations, or...
  16. Re: c++ 11 - can i override functions without re-declare them?

    If I remember correctly, Cambalinho actually asked this question before, or questions along similiar lines. Something about using C++ as an intermediate language, but I didn't understand why the...
  17. Replies
    14
    Views
    368

    Re: How to solve this factorial

    Yeah, it isn't clear if "by using goto command" means that there has to be sensible use of a goto somewhere, or if it means that only goto can be used. However, without a label, one cannot use a...
  18. Re: c++ 11 - can i override functions without re-declare them?

    You cannot override ola without declaring it in test1.
  19. Replies
    9
    Views
    381

    Re: Casting Pointers in C style?

    A pointer's value is an address. Therefore, casting to an int pointer results in an address (with the specified pointer type). In this, the syntax doesn't matter; the semantics is that you get a...
  20. Replies
    14
    Views
    368

    Re: How to solve this factorial

    Eh, are you supposed to write a C++ program that computes that double factorial? If so, the requirement to use goto is very strange, unless you already know how to do this without using goto and can...
  21. Re: A question regarding throwing an exception

    If you comment out the throw 2, then when the lifetime of A ends because it goes out of scope, its destructor is invoked, leading to throw 1, which is then caught.


    Sorry, typo error. It should...
  22. Re: A question regarding throwing an exception

    It only catches the exception thrown at throw 1. When that happens, the destructor is invoked, causing the exception from throw 1 to be thrown and not caught.
  23. Re: A question regarding throwing an exception

    True. However, if you are throwing exceptions from a destructor in order to catch it in that destructor, then you are probably misusing exceptions.


    Yes. This is mentioned in the article.
  24. Re: A question regarding throwing an exception

    Read: GotW #47: Uncaught Exceptions. Basically, you should not be throwing an exception from within a destructor.
  25. Replies
    48
    Views
    1,615

    Re: Is this guaranteed to be correct?

    As in the cost of typeid and conversion to std::type_index was too high?
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center