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

  1. Replies
    7
    Views
    577

    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...
  2. Replies
    11
    Views
    1,831

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

    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...
  4. Replies
    11
    Views
    1,831

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

    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,...
  6. Replies
    11
    Views
    1,831

    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)...
  7. Replies
    11
    Views
    1,831

    Re: Palindromes in Python

    It really doesn't have to be that complex:

    def isPalindrome(text):
    return text == ''.join(reversed(text))
  8. Replies
    14
    Views
    919

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

    by laserlight
    Replies
    4
    Views
    579

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

    by laserlight
    Replies
    1
    Views
    530

    Re: class

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

    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...
  15. Replies
    5
    Views
    717

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

    by laserlight
    Replies
    9
    Views
    852

    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)...
  17. Replies
    6
    Views
    639

    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,...
  18. Replies
    6
    Views
    917

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

    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...
  20. Replies
    31
    Views
    2,088

    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...
  21. 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.
  22. Replies
    1
    Views
    437

    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++...
  23. Replies
    7
    Views
    1,065

    Re: Token pasting

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

    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...
  25. Replies
    4
    Views
    3,453

    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...
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)