Search:

Type: Posts; User: serge

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    71

    Wow, thank you for fixing the code, I really...

    Wow, thank you for fixing the code, I really appreciate it!
  2. Replies
    2
    Views
    71

    Pass bitset pattern to constructor

    Hello,

    How can I pass an expression similar to the one I commented out (instead of the binary representation) to the constructor? I would like to make the constructor argument more readable.


    ...
  3. Yes, this works! Thank you!

    Yes, this works! Thank you!
  4. Unique pointer and a vector in the class constructor

    Hello,

    I was mildly surprised when I realized that I cannot initialize the vector directly like in the commented out command, but have to use a default constructor. Surprised because...
  5. Replies
    7
    Views
    249

    You mean like this? Engine&...

    You mean like this?



    Engine& operator=(const Engine&) = delete;
    Engine& operator=(Engine&&) = delete;


    The problem I had is if I put this in engine.h
  6. Replies
    7
    Views
    249

    I have a follow up issue that I cannot solve even...

    I have a follow up issue that I cannot solve even after checking a few examples on the net. How do I declare the two entities in a header and a cpp file so that function can reach the destructor?...
  7. Replies
    7
    Views
    249

    Thanks to both of you. I realized that I don't...

    Thanks to both of you. I realized that I don't need y base class at all, so the problem became simpler. Yes, checking error messages does help in most cases.
  8. Replies
    7
    Views
    249

    Simple factory pattern

    Hello,

    how can pass a value to the constructor of the derived structs in this simple factory pattern? thx



    #include <iostream>
    #include <memory>
    #include <vector>
  9. Replies
    1
    Views
    100

    On the use of inline

    I have read the following statement (partial quote):

    "A reasonable rule of thumb is to not put inline at functions that have more than 3 lines of code in them."

    Does this rule of thumb apply if...
  10. void myprint(const short *src[], size_t len) ...

    void myprint(const short *src[], size_t len)

    fixed it.
  11. But something still is not right, for the two...

    But something still is not right, for the two print calls produce different output:



    void myprint(const short *src, size_t len)
    {
    int i;
    for(i = 0; i < len; ++i) printf("%d\n", src[i]);
    }
  12. OK thanks! So, in my example, the pointer has...

    OK thanks!

    So, in my example, the pointer has been passed correctly but I need to pass the size separately (if I want to do something in the function).

    Just of curiosity, what did my function...
  13. Pass array pointer to function and compute size of array

    Hi,

    why does the function return an incorrect value, here 2 instead of 5?



    #include <stdio.h>

    size_t len(const short (*arr))
    {
  14. Replies
    8
    Views
    266

    But still it should be possible to recast...

    But still it should be possible to recast pointers of unrelated classes, I just can' wrap my head around how:

    Something like this should doable:



    auto A = nullptr;
    if (true) {
    MyType B =...
  15. Replies
    8
    Views
    266

    Another question that came to my mind is why does...

    Another question that came to my mind is why does inserting e.g. weapon in loadout increase the counter of shared pointers (I am using shared)? My types are:



    typedef std::shared_ptr<Weapon>...
  16. Replies
    8
    Views
    266

    Thank you very much! I will rethink the style...

    Thank you very much! I will rethink the style (still very new to cpp, and it shows). Over the past few months, I have learnt so much from all of you in this forum and I greatly appreacite it.

    I...
  17. Replies
    8
    Views
    266

    Ah..get it! So I need: WeaponPtr...

    Ah..get it! So I need:



    WeaponPtr leftweapon = nullptr;
    WeaponPtr rightweapon = nullptr;
  18. Replies
    8
    Views
    266

    An issue with Switch (Scope?)

    Hello,

    I have a function similar to this for character construction (types omitted).

    The switch statement does not work. I though it is an issue of score, but setting curly brackets inside each...
  19. Replies
    13
    Views
    294

    Yes, I made a cut-and-paste error - vector should...

    Yes, I made a cut-and-paste error - vector should be element. The problem that I have is this:

    1. Header (utilities.h)



    #ifndef UTILITIES_H
    #define UTILITIES_H
    #pragma once
  20. Replies
    13
    Views
    294

    To follow up on templates. Putting this function...

    To follow up on templates. Putting this function in the header (along with
    #include <iostream> and
    #include <vector>)



    template <typename T>
    void PrintVector(const std::vector<T>& vector)...
  21. Replies
    13
    Views
    294

    OK, I missed that! So where should the second...

    OK, I missed that! So where should the second line go, given that the type is used in practically the whole program, i.e. certainly downstream of dice.h. Does it need to stay global?
  22. Replies
    13
    Views
    294

    Yes, this works if I put implementations in the...

    Yes, this works if I put implementations in the header, but i would like to have a clean header file and a cpp file with function bodies. The below pattern currently produces an mt19937 error:

    So...
  23. Replies
    13
    Views
    294

    Typedef declaration and header files

    Hi,

    Where should I put typedef that is used in several header files? Putting it in each file causes multiple declaration error, and yet each header file requires a declaration. Should I play...
  24. Ah.. nice! Thx again

    Ah.. nice! Thx again
  25. Arguments of lambda functions need to be local?

    Hello,

    I just wanted to check on this. I have the statement below inside a function (method of Player) that checks that all weapons in the Loadout vector has the same scale as the Player who...
Results 1 to 25 of 113
Page 1 of 5 1 2 3 4