I'm trying to automate this crazy formatting ritual I go through at the end of each month to create income statements. I need three versions of it. One for board members, IRS, etc.. - just kidding ;) The different versions will group GL amounts in differing categories to align with budget projections. My thought was to create a report object and store the mappings in text files....
So, I'm wondering if there is a way to create a file name that comes from a user input. This way I could save old versions or create new reports, etc... Plus I'm lazy and would like to cut down on the amount of code I have to write - thank you objects! :)
It will be nice when professors stop instructing their students to install non-compliant C++ compilers from the 80s and 90s. Or rather, when we run out of those professors and they get replaced by next-gen professors. Mmmmmm, yummy next-gen professors.
(Though obviously the feature mentioned by JLBorges was only widely adopted a couple years ago)
I’m admittedly pretty amateur. I took two c++ classes, probably 7 years ago. I make mini programs to take shortcuts in my accounting life. (Very useful when you are being forced against your will to use crap software)
LB - can you recommend a good compiler?
Also, JLBorges - I appreciate the notes about flushing, but I'm not familiar with the concept. :0 Would you mind elaborating?
> I appreciate the notes about flushing, but I'm not familiar with the concept.
Streams have an associated stream buffer; when we write to an output stream, the bytes are held in the stream buffer instead of being immediately sent to a physical device such as stdout or a file. Eventually, when the buffer becomes full, or the stream is closed, it is 'flushed' - ie pending bytes are physically written to the device. (It would be inefficient to write each byte separately to a physical device.)
We can force an output stream to immediately flush the buffer via the member function flush(). The manipulator std::endl writes a new line to the output stream and then calls flush() on it.
By default, std::cout is tied to std::cin; this causes std::cout to be flushed before each input from std::cin
A good compiler is one that supports the latest C++ standard, which used to be C++03, is now C++11, and will soon be C++14. Currently gcc/mingw 4.8 with the -std=c++11 flag support a good deal of C++11, and clang 3.3 with the -std=c++11 flag supports a good deal too. I recommend clang if you can.
But catching up on everything added to C++ in the last 7 years PLUS refreshing your memory will be a challenge ;)
JLBorges - I see, I vaguely remember some funkiness with getline in certain places. Maybe it was a flushing issue. I'll do some more reading. Thanks for the flushing lesson and the link! I'm all for reducing redundancy and maximizing efficiency. :)
LB - Thanks for the recommendations, I will do some compiler shopping.
Thank you both for your help, I really appreciate it!