Search:

Type: Posts; User: jason_m

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    16
    Views
    4,813

    Oh I see. For example, you could delete the...

    Oh I see. For example, you could delete the object at that address. That wouldn't be very nice to everyone else holding a pointer to the ModelReader. Would using a std::shared_ptr resolve all of...
  2. Replies
    16
    Views
    4,813

    Sorry, I wasn't very clear. My example resulted...

    Sorry, I wasn't very clear. My example resulted in a seg fault, that was the intention - to access a member of the Model before it was finished being constructed.

    The next paragraph was about my...
  3. Replies
    16
    Views
    4,813

    Thanks for the feedback. My specific take away...

    Thanks for the feedback. My specific take away from this is it is fine to store the pointer; it is not okay to dereference it or try to access any members through it.

    So I've re-worked the...
  4. Replies
    16
    Views
    4,813

    Using this pointer in constructor

    I've read before that using the this pointer in a constructor should be avoided. Generally I can understand that the object may not be entirely constructed yet, but I've never understood entirely...
  5. Replies
    9
    Views
    4,796

    I'm not sure I picture how this would work. To...

    I'm not sure I picture how this would work. To provide a little more information on the input, the number of cash flows is variable. On average, there will probably be around 100. Everything comes...
  6. Replies
    9
    Views
    4,796

    Your code is more compact, but there is a reason...

    Your code is more compact, but there is a reason my loop is laid out how it is. The input may come in multiple formats. The input items are actually cash flows. Optionally, a time may also be...
  7. Replies
    9
    Views
    4,796

    Well, putting together a stripped down example of...

    Well, putting together a stripped down example of a parent process passing data to my program lead me to the problem/solution.

    For completeness, here's the other program:



    #include...
  8. Replies
    9
    Views
    4,796

    I see. As my first post alluded to, ultimately I...

    I see. As my first post alluded to, ultimately I would like to call this program from another, send it input, and read its output. Tonight after work, I'll write up and post a little test calling...
  9. Replies
    9
    Views
    4,796

    scanf(), whitespace, and EOF

    Hi,

    I'm trying to parse whitespace-delimited doubles out of an input stream. I'm having trouble properly detecting the end of the file. Here is a small program which reproduces this:


    ...
  10. Replies
    11
    Views
    1,557

    Yeah, knowing what I now do about the stream...

    Yeah, knowing what I now do about the stream evaluating to false when EOF is encountered, I agree this is probably the nicest approach. Cleaner looking that "while(inSFile.get(ch).good())" and does...
  11. Replies
    11
    Views
    1,557

    Ah, I didn't realize the while condition would...

    Ah, I didn't realize the while condition would evaluate to false when EOF was encountered.

    I'm curious though about ch being of type char. get() returns an int, so I was expecting that g++ with...
  12. Replies
    11
    Views
    1,557

    Yes, you could follow what the example in that...

    Yes, you could follow what the example in that link did. I don't like it as much because it needs to check for EOF twice. You can make it more compact while still being readable IMO. Perhaps...
  13. Replies
    11
    Views
    1,557

    This is not true. I suspect you are thinking...

    This is not true. I suspect you are thinking that get() returns an integer which will correspond to the character read, or some negative value in the case of EOF. However, the return value of...
  14. Thread: enum

    by jason_m
    Replies
    16
    Views
    2,082

    Maybe the instructor is thinking of Java enums?...

    Maybe the instructor is thinking of Java enums?
    Enum Types (The Java™ Tutorials > Learning the Java Language > Classes and Objects)


    As far as C++ goes, I would think a std::map would work here...
  15. Replies
    7
    Views
    1,360

    It might simply things a bit also if you wrapped...

    It might simply things a bit also if you wrapped your suit and value together in a struct or class. Something like



    enum CardValue { ... };
    enum CardSuit { ... };

    struct Card {
    ...
  16. Replies
    16
    Views
    2,132

    Each row *cannot* have a variable number of...

    Each row *cannot* have a variable number of columns. For this reason I have changed the internal representation to simply be a vector, rather than a vector of vectors. The table holds decrement...
  17. Replies
    16
    Views
    2,132

    Yes, you are correct, I meant export.

    Yes, you are correct, I meant export.
  18. Replies
    16
    Views
    2,132

    Yes, that being the way I have done things before...

    Yes, that being the way I have done things before for non-template functions.

    I found this to be a good write-up on the subject:
    [35] Templates, C++ FAQ Lite

    Looking over the options, I guess...
  19. Replies
    16
    Views
    2,132

    If I break my code up the way I am used to: - A...

    If I break my code up the way I am used to:
    - A header file MyTable.h that only declares member functions
    - An implementation file MyTable.cpp that defines/implements those functions, and
    - A...
  20. Replies
    16
    Views
    2,132

    Thank you for all of your replies, you have...

    Thank you for all of your replies, you have helped me out a lot. The last thing I am trying to decide is whether I should use two iterators - a begin and an end, or do like CodeMonkey's example, and...
  21. Replies
    16
    Views
    2,132

    I shouldn't post past my bed time. Of course the...

    I shouldn't post past my bed time. Of course the class would need to be a template too. Otherwise what would the syntax be for calling the constructor? Doubt the compiler would figure it out on...
  22. Replies
    16
    Views
    2,132

    If I went the route of using an iterator, then I...

    If I went the route of using an iterator, then I for simplicity, I think I'll require the iterator to iterate over a 1 dimensional set of doubles. That is, the 1d set spans the entire table, columns...
  23. Replies
    16
    Views
    2,132

    Filling in a table

    Hi, I'm pondering a design decision (which I find to be the hard part):

    I have a y-by-x table where y and x are passed in by the user, and I'm looking for ideas on how to create a concise...
  24. Replies
    2
    Views
    943

    Some snippets from your code: string x;...

    Some snippets from your code:



    string x;
    ...
    string q;
    ...
    cout << x + q << endl;
  25. Replies
    8
    Views
    13,663

    @laserlight: This compiles, so when initializing...

    @laserlight: This compiles, so when initializing the static member variable, its type definition needs to be repeated? Is that what I should take from this?

    @whiteflags: You are absolutely right,...
Results 1 to 25 of 87
Page 1 of 4 1 2 3 4