Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.07 seconds; generated 24 minute(s) ago.

  1. Replies
    1
    Views
    32

    Yes, you can, but you may end up injecting more...

    Yes, you can, but you may end up injecting more unqualified names into the scope than you expect, so you shouldn't unless you know what you're doing.
  2. Replies
    7
    Views
    194

    Then don't do that :) The class definition...

    Then don't do that :)

    The class definition should go in the header unless you're trying for the pimpl (opaque pointer) idiom... but in that case in C++ you would still have a class wrapper; it's...
  3. You should not have functions just for the sake...

    You should not have functions just for the sake of having functions. Rather, use functions to simplify repetitive code that should be reused instead, or use them to group sections of code and name...
  4. Replies
    7
    Views
    194

    Post the corresponding error message, don't just...

    Post the corresponding error message, don't just refer to it.

    This compiles for me without even a warning on g++ 7.4.0:

    #include <iostream>
    #include <memory>

    struct Engine
    {
    const...
  5. The address of Ptr->number is &Ptr->number, not...

    The address of Ptr->number is &Ptr->number, not Ptr->number.

    But why do you want to know its address? What's the point? I showed you a simple example in post #8 and asked you two related questions...
  6. Refer to my previous post.

    Refer to my previous post.
  7. Well okay. If you want to clarify what are the...

    Well okay. If you want to clarify what are the addresses of a struct object versus its data members, then yes, that's a good time to print addresses. But it really doesn't have to be so hard:
    ...
  8. Stop bothering with printing addresses/pointers....

    Stop bothering with printing addresses/pointers. If you want to know if space has been allocated by malloc, check that the return value of malloc is not a null pointer. That's all that you need to...
  9. They are the same by definition: the address-of...

    They are the same by definition: the address-of operator & results in a pointer to the operand.

    If you really must, you can do the rather pointless exercise of:

    #include <stdio.h>

    struct...
  10. That's good to know, but you still haven't...

    That's good to know, but you still haven't answered my question, e.g., change it to a vector<string> of two strings, "a" and "b". What would the resulting char be, and how did you arrive at that...
  11. What does it mean to convert a vector to...

    What does it mean to convert a vector<string> to char? For example, suppose you have a vector<string> with two strings, "hello" and "world!". What would the resulting char be, and how did you arrive...
  12. Replies
    2
    Views
    83

    In main.cpp, you have these two lines before the...

    In main.cpp, you have these two lines before the main function:

    std::string input;
    std::string*pInput =&input;
    Get rid of them as they should be in the main function instead, and in fact you do...
  13. It is a bit difficult to see what lines the error...

    It is a bit difficult to see what lines the error messages correspond to. Post the smallest and simplest program that you expect should compile but which demonstrates the errors (this means that you...
  14. Instead of a default argument, add a...

    Instead of a default argument, add a two-parameter overload that forwards to the three-parameter version:

    char* function(char* a, int b, char** c) {
    // ...
    }

    char* function(char* a, int...
  15. Replies
    4
    Views
    185

    Those aren't tokens though. After lexical...

    Those aren't tokens though. After lexical analysis, the tokens would be "j", "=", "+", "3" for the former. The parser would then parse and understand that the adjacent tokens "+" and "3" are grouped...
  16. Replies
    1
    Views
    92

    Do that, followed by a statement (also in the...

    Do that, followed by a statement (also in the else block) with the break keyword.
  17. Replies
    3
    Views
    121

    Where did you allocate space for the struct...

    Where did you allocate space for the struct person object?
  18. Replies
    3
    Views
    117

    So... you understand what's going on now?

    So... you understand what's going on now?
  19. Replies
    3
    Views
    117

    pointer[i] is an int; &array[i] is a pointer to...

    pointer[i] is an int; &array[i] is a pointer to int. How could they be the same thing?
  20. Replies
    7
    Views
    194

    You did so successfully. What you didn't do...

    You did so successfully.

    What you didn't do successfully was trying to access a member specific to derived classes on the elements of a vector of base class smart pointers:

    for(const auto& v :...
  21. * moved to C++ programming forum *

    * moved to C++ programming forum *
  22. Replies
    4
    Views
    137

    Explain why you have such a doubt.

    Explain why you have such a doubt.
  23. Replies
    4
    Views
    137

    Just print the pointer whose value was returned...

    Just print the pointer whose value was returned by malloc:

    printf(" address : %p \n", (void*)st);
  24. You're basically creating an object merely to...

    You're basically creating an object merely to serve as documentation, and it really is just documentation as you could have just as easily written by mistake:

    Character Knight("Knight",...
  25. Replies
    2
    Views
    137

    Draw on paper a singly linked list with say, 4...

    Draw on paper a singly linked list with say, 4 nodes. Pick a node and think about how you might go about doing it. Pick another node, say the first and last and go through how you would delete it....
Results 1 to 25 of 494
Page 1 of 20 1 2 3 4