Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

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

  1. You should not have the member functions do...

    You should not have the member functions do interactive I/O like that.
  2. You didn't post your current code.

    You didn't post your current code.
  3. Replies
    1
    Views
    42

    Both are correct. I mean, you're just regarding...

    Both are correct. I mean, you're just regarding one file as the "first" and the other as the "second", then swapping over the designations in the next example.

    A more common way of doing this is...
  4. What is your current code? Also, post your test...

    What is your current code? Also, post your test input, expected output, and (as far as you can) actual output.
  5. 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.
  6. Err... the return type is right there for you to...

    Err... the return type is right there for you to see: struct student *
  7. 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...
  8. Replies
    3
    Views
    90

    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...
  9. Replies
    1
    Views
    60

    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.
  10. Replies
    7
    Views
    207

    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...
  11. 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...
  12. Replies
    7
    Views
    207

    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...
  13. 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...
  14. Refer to my previous post.

    Refer to my previous post.
  15. 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:
    ...
  16. 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...
  17. 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...
  18. 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...
  19. 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...
  20. Replies
    3
    Views
    116

    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...
  21. 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...
  22. 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...
  23. Replies
    4
    Views
    201

    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...
  24. Replies
    1
    Views
    98

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

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

    Where did you allocate space for the struct...

    Where did you allocate space for the struct person object?
Results 1 to 25 of 494
Page 1 of 20 1 2 3 4