Search:

Type: Posts; User: AH_Tze

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    20
    Views
    2,806

    It's unnecessary. Simply be looking at the...

    It's unnecessary. Simply be looking at the control statement you should be able to understand what variables control the loop, and what conditions the loop continues/stop execution.

    There are...
  2. Replies
    41
    Views
    5,132

    A string and an array of chars have similiar...

    A string and an array of chars have similiar functionality. Strings are preferred unless it's part of the program specification (some teachers have a fetish for char arrays (c-strings))

    Could you...
  3. Replies
    41
    Views
    5,132

    I'm not quite following the program logic, but it...

    I'm not quite following the program logic, but it looks like you need a sub loop.

    For a given string, you could have something like:


    // I think key is the right string
    for(int current = 0;...
  4. Replies
    11
    Views
    1,066

    Now I'm curious. I ran this, and checked strlen()...

    Now I'm curious. I ran this, and checked strlen() immediately after input, which gave lengths greater than the size of the array. Is the program writing past it's bounds?

    If so, you might want to...
  5. Replies
    11
    Views
    1,066

    I just ran it (sans missing end bracket on name),...

    I just ran it (sans missing end bracket on name), and it worked. It read in first 20 characters and ignored the rest when assigning name. Seemed to have the same behavior as when I used a name that...
  6. Replies
    22
    Views
    1,804

    well if it's time for that conversation... ...

    well if it's time for that conversation...

    Accelerated C++ by Koenig and Moo is a great book, especially if you have past programming experience and want to start using the powerful tools C++...
  7. Replies
    22
    Views
    1,804

    You could make a class which knows it's name is a...

    You could make a class which knows it's name is a user-entered string. ie it could output, change, and compare it's "name."

    I'm going to have to join the people who are very confused about why...
  8. Replies
    7
    Views
    1,101

    You're asking for a bool but getting...

    You're asking for a bool but getting string::size_type.
    It will always evaluate to true except for when the target string is the first character of someString.
  9. Replies
    7
    Views
    1,101

    The -1 is an implementation detail. If you used...

    The -1 is an implementation detail. If you used it, you'd be obfuscating what you're doing and assuming the compiler will give it the correct type.
  10. Replies
    7
    Views
    1,101

    If you're looking for an explanation, many...

    If you're looking for an explanation, many (most/all?) implementations define npos as such (in logic if not in syntax):


    size_type npos = -1;

    size_type is going to be some type of unsigned...
  11. Replies
    3
    Views
    2,140

    Not sure I understand. Are you trying to derive a...

    Not sure I understand. Are you trying to derive a vector sub-class that provides bounds checking?

    If so, vector::at() already does bounds checking. It throws a std::out_of_range exception if the...
  12. Replies
    2
    Views
    894

    what happens if you have a const Array_class?

    what happens if you have a const Array_class?
  13. Thread: Minor Problem

    by AH_Tze
    Replies
    5
    Views
    987

    Much cleaner. String has been implemented so you...

    Much cleaner. String has been implemented so you can use the stream insertions with it (cout << and cin>>). You can also directly compare them, no messing around with strcmp.



    #include...
  14. Thread: Minor Problem

    by AH_Tze
    Replies
    5
    Views
    987

    You can't use cout on a c-string. I'm not sure...

    You can't use cout on a c-string.
    I'm not sure what the best way to output a c-string is (you could write the function to loop through and print each char, but it may have been done better/before...
  15. Replies
    6
    Views
    1,869

    Could he mean if there is a new[] inside a...

    Could he mean if there is a new[] inside a conditional? At which point this might happen:


    int* ptr_var = 0;

    //... possibility of ptr_var = new int[SIZE]

    delete [] ptr_var;
  16. Replies
    4
    Views
    1,140

    okay, a function uses pass by reference can...

    okay, a function uses pass by reference can handle a literal, but only if the parameter is constant .
    I'm guessing that this shouldn't be a problem for an Add() function. The only time you'd need a...
  17. Replies
    4
    Views
    1,140

    As you discovered, C++ views literals differently...

    As you discovered, C++ views literals differently as they don't have addresses.

    EDIT: Damn, that was stupid.
    /me goes off to play with this, ignore the following as it doesn't work.
    There must...
  18. Replies
    11
    Views
    1,230

    Wouldn't using the std namespace in a class...

    Wouldn't using the std namespace in a class pollute the namespace of any code the uses the class?
  19. Replies
    3
    Views
    948

    marginally related question, but would there be a...

    marginally related question, but would there be a real value in using a global variable for E instead of a macro? I remember hearing something to that effect, but I couldn't follow the justification...
  20. Replies
    8
    Views
    1,385

    What is the point of this "house house" thing? ...

    What is the point of this "house house" thing?

    Within a class' method, such as menu(), you have access to all of the class member data and methods, so why would you need to make a new object of...
  21. Thread: Game of life

    by AH_Tze
    Replies
    30
    Views
    7,790

    Not seeing it immediately. The alive() and...

    Not seeing it immediately. The alive() and neighbor() functions look error-prone.
    If you want to find the error, I'd probably write a seperate driver program so you can test those two individually....
  22. Thread: Game of life

    by AH_Tze
    Replies
    30
    Views
    7,790

    i'm piecing through this. One random style...

    i'm piecing through this. One random style suggestion, is that you should really use 0-indexed lists. If you don't stick with the idiom, it gets confusing, as you always have to keep track of if code...
  23. Thread: Game of life

    by AH_Tze
    Replies
    30
    Views
    7,790

    Interesting. What does the input file look like?

    Interesting. What does the input file look like?
  24. Replies
    5
    Views
    1,765

    This sounds a lot like either an assignment, or...

    This sounds a lot like either an assignment, or something you should be doing yourself.

    I like being helpful, but not doing your work for you. If you have a conceptual, syntactic, or just really...
  25. Thread: c++ Templates

    by AH_Tze
    Replies
    5
    Views
    1,120

    The logic is not too hard. The general concept...

    The logic is not too hard.

    The general concept is to start by assuming the first element is the largest.
    Then compare the current maximum value the next element. If the next element is larger,...
Results 1 to 25 of 82
Page 1 of 4 1 2 3 4