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...
Type: Posts; User: jason_m
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...
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...
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...
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...
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...
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...
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...
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...
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:
...
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...
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...
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...
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...
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...
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 {
...
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...
Yes, you are correct, I meant export.
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...
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...
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...
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...
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...
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...
Some snippets from your code:
string x;
...
string q;
...
cout << x + q << endl;
@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,...