dcsimg
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 2.25 seconds.

  1. Replies
    11
    Views
    604

    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...
  2. Replies
    2
    Views
    343

    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...
  3. Replies
    11
    Views
    604

    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...
  4. Replies
    11
    Views
    604

    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,...
  5. Replies
    11
    Views
    604

    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)...
  6. Replies
    11
    Views
    604

    Re: Palindromes in Python

    It really doesn't have to be that complex:

    def isPalindrome(text):
    return text == ''.join(reversed(text))
  7. Replies
    14
    Views
    590

    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...
  8. 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
  9. 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...
  10. Thread: Destructor

    by laserlight
    Replies
    4
    Views
    519

    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 {
    ...
  11. Thread: class

    by laserlight
    Replies
    1
    Views
    440

    Re: class

    Post the smallest and simplest compilable version of your program that demonstrates this error.
  12. 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...
  13. Replies
    14
    Views
    1,543

    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...
  14. Replies
    5
    Views
    681

    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...
  15. Thread: operator+

    by laserlight
    Replies
    9
    Views
    809

    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)...
  16. Replies
    6
    Views
    597

    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,...
  17. Replies
    6
    Views
    867

    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...
  18. Replies
    31
    Views
    2,001

    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...
  19. Replies
    31
    Views
    2,001

    Re: using namespace std

    You don't have to use using directives like using namespace std at all, e.g., you could fully qualify the names, e.g., instead of cout write std::cout. If you do want to use them, then the idea is to...
  20. Re: why i must use an object when i have a virtual function on a class?

    It is a non-static member function, so it must be called via an object. That it is a virtual function is secondary.
  21. Replies
    1
    Views
    420

    Re: Linking stage

    Refer to the GCC manual on Compiling C++ Programs:

    As such, you did not need to explicitly link against the C++ standard library despite using <iosteam> and <cstring> because you compiled with g++...
  22. Replies
    7
    Views
    1,006

    Re: Token pasting

    I would think that using the preprocessor for this is a hack compared to just using an array of function pointers.
  23. Replies
    5
    Views
    1,116

    Re: define operator assignment

    Yes, you can.


    The typical copy assignment operator would return the object itself by reference. This allows for operator chaining, which could be useful.

    Instead of implementing memory...
  24. Replies
    4
    Views
    3,325

    Re: Overriding the constructor

    Well, then the answer should be fairly obvious: when your derived class objects need to be initialised in a way not anticipated by the base class. I'm sure you have come across such cases in other...
  25. Replies
    4
    Views
    3,325

    Re: Overriding the constructor

    As in define a constructor in a derived class, perhaps one that invokes a base class constructor?

    I'm curious what prompted this question, i.e., what made you ask this question?
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




On-Demand Webinars (sponsored)