Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.08 seconds.

  1. Don't you have examples of that in your learning...

    Don't you have examples of that in your learning material? Your stringP function already does that, except that it is badly named and looks like it isn't correctly implemented.
  2. Err... the return type is right there for you to...

    Err... the return type is right there for you to see: struct student *
  3. If you're talking about how to save the displayed...

    If you're talking about how to save the displayed output to a string: do it in the opposite order, i.e., write a function that generates the required string, then print the string or do whatever else...
  4. Replies
    3
    Views
    81

    I suggest that you post a compilable program...

    I suggest that you post a compilable program rather than just a fragment with unexplained parts. I can make guesses based on what I see, but why guess when you can post the definitions of param_1 and...
  5. Replies
    1
    Views
    55

    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.
  6. Replies
    7
    Views
    201

    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...
  7. 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...
  8. Replies
    7
    Views
    201

    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...
  9. 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...
  10. Refer to my previous post.

    Refer to my previous post.
  11. 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:
    ...
  12. 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...
  13. 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...
  14. 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...
  15. 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...
  16. Replies
    2
    Views
    85

    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...
  17. 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...
  18. 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...
  19. Replies
    4
    Views
    190

    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...
  20. Replies
    1
    Views
    95

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

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

    Where did you allocate space for the struct...

    Where did you allocate space for the struct person object?
  22. Replies
    3
    Views
    120

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

    So... you understand what's going on now?
  23. Replies
    3
    Views
    120

    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?
  24. Replies
    7
    Views
    201

    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 :...
  25. * moved to C++ programming forum *

    * moved to C++ programming forum *
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4