Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.10 seconds; generated 25 minute(s) ago.

  1. Replies
    1
    Views
    44

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

    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...
  5. Replies
    1
    Views
    84

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

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

    Where did you allocate space for the struct...

    Where did you allocate space for the struct person object?
  7. Replies
    3
    Views
    109

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

    So... you understand what's going on now?
  8. Replies
    3
    Views
    109

    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?
  9. Replies
    3
    Views
    151

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

    * moved to C++ programming forum *
  11. Replies
    4
    Views
    126

    Explain why you have such a doubt.

    Explain why you have such a doubt.
  12. Replies
    4
    Views
    126

    Just print the pointer whose value was returned...

    Just print the pointer whose value was returned by malloc:

    printf(" address : %p \n", (void*)st);
  13. 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",...
  14. Replies
    2
    Views
    129

    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....
  15. If you want to use st, why are you still...

    If you want to use st, why are you still declaring and using p1?
  16. Err... N is just a member of the struct. It...

    Err... N is just a member of the struct. It doesn't tell you how much memory has been allocated. Furthermore, you printed its value before assigning it an initial value, so you got garbage.
  17. Actually, we always dynamically allocate memory...

    Actually, we always dynamically allocate memory for objects, where an object is some region of memory storing a value of some type. So, an object could be of pointer type, of some struct type, of...
  18. Why do you want to dynamically allocate memory?

    Why do you want to dynamically allocate memory?
  19. Replies
    4
    Views
    216

    Oh dear, my apologies, my turn to not see that...

    Oh dear, my apologies, my turn to not see that this was posted in the C programming forum. The C++11 rules are likely to be consistent with C99 though as that's the C++11 reference for constructs...
  20. Replies
    4
    Views
    216

    Both of these are directly addressed by the C++...

    Both of these are directly addressed by the C++ standard:

    So, 2 >> -1 results in undefined behaviour, 2 >> 5 results in zero, and -2 >> 1 has an implementation-defined result.


    Both of these...
  21. Replies
    7
    Views
    212

    Yes, except that your problem has to do with you...

    Yes, except that your problem has to do with you mixing up a function declaration versus a function call.


    Thankfully, multiple errors are sometimes due to the same mistake. Take these four...
  22. Replies
    2
    Views
    152

    Your first struct declaration is not...

    Your first struct declaration is not syntactically correct in the first place. Perhaps what you wanted to do was this:

    struct student {
    char name[30];
    int rollNo;
    struct dateOfBirth...
  23. Since you're using such a recent IDE with a...

    Since you're using such a recent IDE with a compiler that supports C++17, have you considered using the standard filesystem library instead?
  24. Replies
    9
    Views
    146

    The second is probably better: you can just take...

    The second is probably better: you can just take the address of the local variable at the end. No need to worry about unique_ptr and even think about memory management.
  25. Replies
    9
    Views
    146

    Yes, but then you won't meet your "create struct...

    Yes, but then you won't meet your "create struct instance on heap" requirement.
Results 1 to 25 of 494
Page 1 of 20 1 2 3 4