I ended up looking the official answer book and they actually used a similar method. They managed to do it in one while loop by properly working down the exceptions.
Type: Posts; User: jaxdid
I ended up looking the official answer book and they actually used a similar method. They managed to do it in one while loop by properly working down the exceptions.
I'm a newbie but well done. Prior programming experience outside of c++?
Are constructors basically there to initialize data members in a class?
So I recently attempted the following exercise:
My solution?
#include <iostream>
Weird, do you get locked out of editing your own posts?
@Laserlight Thanks, this isn't my code but an answer provided by the book - formatting went weird after I copy pasted and I retyped it, my...
#include iostream
using std::cout;
using std::endl;
// include definition of class Invoice from Invoice.h
#include "Invoice.h"
// Invoice constructor initializes the class's four data...
Sorry I meant determine both largest and smallest number. Basically I want to be able to reject commas if they are included by user without producing an error and keeping code fairly simple. ...
Morning!
Rather straightforward exercise. The goal is to determine largest of three numbers but can't use more than if statements (no else, no nested, no && || ). Is this the most efficient code...
Wow, thanks a lot. You're the man/woman! Didn't know you could treat the input stream like that.
Thanks for the example code. I'll have to study it. A few new concepts in there I haven't caught up to but that's fine, I get the general jist of it.
What do you think about my example below? ...
For veterans of C++, is getline your preferred way of getting user input? What if you're dealing with both numbers and strings? Storing a number in a string would make computations complicated....
Thanks Elysia, that's the habit I'm going with too.
If I can indulge one more question about getline and input buffers.
#include <iostream>
#include <string>
Thanks to both of you, jocdrew21 and Elkvis. Problem solved.
I was the boob in this case...
Should I look into the wstring, wcout, etc for more info or is that a somewhat complex concept I can...
Sorry do you mind a bit of hand holding here? What would be an example of a string literal in my code where I should stick in the 'L'? Although the compiler did complain when I tried...
I'm on OS X 10.9, using XCode 5.0.2. When I run the code the usual output box doesn't show anything. Although debugger reports using 276 KB of memory, it ends up filling up the space with bars.
Good point unfortunately I had tested that and it still doesn't work. I had previously tried:
std::getline( std::cin, user_first_name, '\n');
Still no change.
Just started in on Allain's book and rather frustratingly ran into issues despite following the book to the letter. I'm trying to wrap my head around how getline works.
The following piece of...