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.10 seconds.

  1. Replies
    6
    Views
    2,924

    Re: virtual function in derived class

    Your declaration of f in D is an overload, not an override. If I remember correctly, it even hides the virtual function f inherited from C.

    What's the "right function" to invoke for the D object...
  2. Re: Why is my class showing up as a absract class

    Neither BaseEntity nor Entity are abstract classes since they don't have any pure virtual member functions (or even any virtual member functions, for that matter).

    What I'm curious about is...
  3. Replies
    7
    Views
    5,203

    Re: sort vector of struct

    No, I think ordinary functions are allowed as long as they take the two required parameters and return bool according to the strict weak ordering requirement. The advantage of a function object lies...
  4. Replies
    9
    Views
    6,883

    Re: switch{case}

    Ah, pardon the lack of clarity: I meant "faster" as in "faster feedback". That is, if you have a question like "will this code below produce this result?", you'll get faster feedback on your question...
  5. Replies
    7
    Views
    5,203

    Re: sort vector of struct

    The comparator is required to model a "less than" comparison, or what they call comparing for "strict weak ordering". What this means is that if A "less than" B is true, then B "less than" A must be...
  6. Replies
    9
    Views
    6,883

    Re: switch{case}

    If you mean '0' to '9' then yes due to fallthrough, but for this kind of question it is usually faster to write a test program and see for yourself.
  7. Replies
    7
    Views
    3,633

    Re: pass to function

    This is unnecessarily convoluted:

    volo *app = new volo(cod, n, c);
    flight.push_back(*app);
    delete app;
    It would suffice to write:

    flight.emplace_back(cod, n, c);
    Even if you had to compile...
  8. Replies
    11
    Views
    18,252

    Re: Palindromes in Python

    Yes, but C++ has a richer library of generic algorithms, and in this case the next function is more akin to the overly generic std::for_each than to a more descriptive generic algorithm. If you look...
  9. Replies
    2
    Views
    7,660

    Re: Remove Whitespaces from the string

    If you want to specifically remove spaces from a string s, then the simplest option would be:

    s.replace(' ', '')
    If you want to remove whitespace in general, then aakashdata's first example would...
  10. Replies
    11
    Views
    18,252

    Re: Palindromes in Python

    Yes, I read your statement again and decided it was unfair to attribute rudeness to you when it can be explained otherwise. My apologies as it means that it is I who became rude.

    For what's it's...
  11. Replies
    11
    Views
    18,252

    Re: Palindromes in Python

    Yes, I agree. My point is that it's also possible to over-engineer to handle things that don't matter, and in general we should be aware of that too.


    I initially took this as a snide remark,...
  12. Replies
    11
    Views
    18,252

    Re: Palindromes in Python

    Sure, but by and large for the kind of strings that people want to check if they are palindromes, this doesn't matter: they are so short that O(N) complexity is meaningless versus amortised O(1)...
  13. Replies
    11
    Views
    18,252

    Re: Palindromes in Python

    It really doesn't have to be that complex:

    def isPalindrome(text):
    return text == ''.join(reversed(text))
  14. Replies
    14
    Views
    2,778

    Re: struct to vector

    If you tested the code, you would have found out that you have a typo on this line:

    pp.pushback(temp);
    It should have been:

    pp.push_back(temp);


    You're probably going to use a loop, so...
  15. Re: Is it possible to send verbose o/p of gcc to text file instead of standard output

    Wouldn't normal input redirection work? Say:

    $ gcc --save-temps --verbose ex1.c -o ex1 2> gcc_errors.txt
  16. Re: srand48() : Unable to compile due to scope issues on Windows in Dev-C++.

    A quick check shows that if the version of MinGW that came bundled with Dev-C++ 5.5.2 properly conformed to POSIX, then #include <stdlib.h> should have been sufficient: you don't need to forward...
  17. Thread: Destructor

    by laserlight
    Replies
    4
    Views
    3,531

    Re: Destructor

    It might be helpful if you printed the addresses of the objects as well, and implemented the copy constructor see it being invoked:

    #include<iostream>

    using namespace std;

    struct st {
    ...
  18. Thread: class

    by laserlight
    Replies
    1
    Views
    5,735

    Re: class

    Post the smallest and simplest compilable version of your program that demonstrates this error.
  19. Re: What are some books and tutorials that focus on larger scale OO refactoring and d

    I'd say that at an architectural level, SRP could be along the lines of dividing a large project into smaller subprojects that do one thing and do it well, although that "one thing" is much larger in...
  20. Replies
    14
    Views
    2,000

    Re: global constants and custom operators

    This is bad for two reasons:

    Your header files are no longer self-contained, i.e., it is now an unusual mysterious convention that when someone includes your header files, they must first have a...
  21. Replies
    5
    Views
    3,870

    Re: friend function

    Why can't it be a member function that takes no arguments? It also, looks like you can just use std::swap to implement the function.

    I note that your Insieme constructor implementation looks...
  22. Thread: operator+

    by laserlight
    Replies
    9
    Views
    1,569

    Re: operator+

    It depends on what does "conversion to int" mean for your class. Once you can clearly define what it means for your class, you can then define it in code. Sometimes (or rather quite often)...
  23. Replies
    6
    Views
    1,033

    Re: Checking For Valid Pointers

    It might or might not be, so you shouldn't assume either way. Rather, you should declare variables near first use so that they can be initialised to point to something, and if that's not feasible,...
  24. Replies
    6
    Views
    2,976

    Re: How use an Abstract class?

    Well, if you want the derived class to be a concrete class such that you can instantiate objects of that class, then you do need to define the pure virtual member functions inherited from the...
  25. Replies
    31
    Views
    3,803

    Re: using namespace std

    Examples are just examples. They can help you to gain in understanding, but you don't have to copy them once you understand what the things they do are about. The point is, you need to understand...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4





Click Here to Expand Forum to Full Width

Featured