Forum: C++ Aug 11th, 2009 |
| Replies: 3 Views: 248 unfortunately, that is completely preference, many people use function overloading for their respective getters and setters
void RandomObject::Value(int newValue) { _value = newValue; } //setter... |
Forum: C++ Aug 9th, 2009 |
| Replies: 3 Views: 334 you will also need to define x, y, a, and first before you can use them in main() |
Forum: C++ Aug 9th, 2009 |
| Replies: 18 Views: 1,138 if I understand correctly, try adding this just before your return statement in "int main()"
cin.get();
that will wait for you to review the data and press enter before exiting the program. ... |
Forum: C++ Aug 9th, 2009 |
| Replies: 1 Views: 222 a couple things I see, first of all, please see the link in my signature for the rules regarding code tags etc, it makes it MUCH easier for us to help you if we can see your code in a comprehensible... |
Forum: C++ Aug 9th, 2009 |
| Replies: 5 Views: 275 your boolean logic is ill-formed inside of your if statements, instead of
if(a==R||r)
//etc.
it should be
if((a == R) || (a == r))
//etc. |
Forum: C++ Aug 7th, 2009 |
| Replies: 5 Views: 240 you misspelled main().... |
Forum: C++ Aug 7th, 2009 |
| Replies: 1 Views: 368 looks like there's a couple things, I don't think that would even compile: comparing a map<int, vector<int> >::iterator to an int inside your loop doesn't seem safe to me. As well as not declaring... |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 972 ironically enough, you missed the entire point of my post, change "int[][10] imageSquare" to "int imageSquare[][10]" and your compiler error will go away |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 378 do you mean if you don't explicitly create a constructor in your class, or are you referring to constructor overloading?
if it's that you don't explicitly create your own, here's what happens
... |
Forum: C++ Aug 6th, 2009 |
| Replies: 7 Views: 972 2 things:
first, arrays are declared like this:
int array[5];
int array2[] = {1, 2, 3, 4, 5};
not like this:
int[5] array; |
Forum: C++ Aug 3rd, 2009 |
| Replies: 7 Views: 275 I think I know what you're after, try having a variable to hold the totals for each value, something like this maybe:
#include<iostream>
using namespace std;
int main()
{
double b... |
Forum: C++ Aug 2nd, 2009 |
| Replies: 9 Views: 299 well, that should give you several problems considering you declared DOB to be an array of size 10
int DOB [10]= {1980,1981,1982,1983,1984,1985,1986,1987,1988,1989};
DOB[12] would put you... |
Forum: C++ Aug 1st, 2009 |
| Replies: 3 Views: 268 sorry, this is a c++ forum, there is a C# forum located elsewhere on this site |
Forum: C++ Jul 21st, 2009 |
| Replies: 11 Views: 592 the syntax for a do-while loop is this:
do
{
//stuff to loop through
}
while(conditions); //note the colon |
Forum: C++ Jul 12th, 2009 |
| Replies: 4 Views: 365 Well, I'll try my best. I'm not that keen on compiler workings, but I would be happy to share how I view the process.
in your time.cpp file, you include time1.h. Ignore that you ever wrote... |
Forum: C++ Jul 12th, 2009 |
| Replies: 4 Views: 365 your problem is in how you are compiling it. You need to compile each .cpp file separately into objects and then link them all together at the end. Give this a try (my g++ flags are a bit rusty,... |
Forum: C++ Jul 10th, 2009 |
| Replies: 10 Views: 502 to answer the OP's question, here's why the total is being affected in a way that you don't think it should. Go through your loop and see what's happening sequentially:
1. tell the user to enter a... |
Forum: C++ Jul 6th, 2009 |
| Replies: 21 Views: 609 no, since you are not altering 'bonus' in displayBonus, you don't need to pass it by reference, you also don't need to return it, you're only displaying what it is.
This looked like a good... |
Forum: C++ Jul 6th, 2009 |
| Replies: 21 Views: 609 global variables ARE a bad idea, which is why it's not the only way to accomplish this with a void function. Try passing things by reference:
void getSales(double &sales); //try this instead... |
Forum: C++ Jun 16th, 2009 |
| Replies: 24 Views: 527 give stringstreams a try for converting from string to integer:
http://www.cppreference.com/wiki/io/sstream/start
http://www.cplusplus.com/reference/iostream/stringstream/ |
Forum: C++ Jun 8th, 2009 |
| Replies: 4 Views: 678 I feel pretty stupid, I found the problem and I know why it's not working in this case and why it does work for my other case (I also know a better alternative, so I guess it's ok). Here was the... |
Forum: C++ Jun 8th, 2009 |
| Replies: 4 Views: 678 thanks for the replies, but it fails before the Show() method, it's in the constructor. And I did isolate the problem further so now the issue has changed scope a little bit. I had forgotten I had... |
Forum: C++ Jun 8th, 2009 |
| Replies: 4 Views: 678 hello, got a quick question regarding stack overflow (I honestly don't know if this is more suited for a wxWidgets forum, once you see what I mean, but I figured I'd try here first). I was tweaking... |
Forum: C++ Jun 3rd, 2009 |
| Replies: 6 Views: 282 2 options for this problem:
1. Add cin.get(); just before your return. This waits for user input before exiting the program.
2. Run the program manually from a terminal. Then you can see the... |
Forum: C++ Jun 1st, 2009 |
| Replies: 3 Views: 257 an alternative to the explicit initiation, is you could change your while loop to a do-while:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int... |
Forum: C++ Jun 1st, 2009 |
| Replies: 3 Views: 906 I personally generally use an EVENT_TABLE if I have a large number of events for a class ( > 5 or so), but if I only have 1 or 2 I generally use Connect (or I have a complicated gui, lots of... |
Forum: C++ May 29th, 2009 |
| Replies: 2 Views: 461 instead of using the ascii codes which would get a bit more complicated when you add numbers because of the disconnect between the codes (since numbers are 48-57 and letters 97-122), why don't you... |
Forum: C++ May 29th, 2009 |
| Replies: 8 Views: 493 that is assuming their password is something like 'b' or '7' (I hope it's not) and just because something compiles doesn't mean it works ;)
this compiles:
#include <iostream>
#include... |
Forum: C++ May 29th, 2009 |
| Replies: 10 Views: 579 besides arrays you should also brush up on for loops...
neither of those will even be entered into (seeing as 1 is NOT greater than or equal to 10). For the first loop you'd need to switch it to... |
Forum: C++ May 28th, 2009 |
| Replies: 14 Views: 433 you forgot to change both declarations of the functions, so the compiler is looking for checkWords(char*) but you only had checkWords(char**).
try:
void checkWords(char*);
void... |
Forum: C++ May 28th, 2009 |
| Replies: 14 Views: 433 looks like you're passing the wrong types to the function (in your implementation). Here's your declaration:
void checkWords(char**); //or void checkWords(char *blah[])
however in your... |
Forum: C++ May 28th, 2009 |
| Replies: 14 Views: 433 void checkWords()
{
int totalWords = 0, uniqueWords = 0;
char *argv[1];
bintree<word> tree;
ifstream file( argv[1] );
you are trying to use the argument passed to main,... |
Forum: C++ May 28th, 2009 |
| Replies: 14 Views: 433 in your revised set of code, try removing the following line:
int main(int, char**);
and what global variables are you referring to? |
Forum: C++ May 28th, 2009 |
| Replies: 10 Views: 532 'unhelpful' responses usually result from misunderstanding what's being asked.... Anyway, if you were trying to get down what 'for' loops do, this tutorial looked decent:
... |
Forum: C++ May 28th, 2009 |
| Replies: 9 Views: 258 check my last post, looks like you overlooked it.....
Here are things to help us solve issues with people's programs:
- Sample input/output (none provided)
- Desired input/output (none... |
Forum: C++ May 28th, 2009 |
| Replies: 9 Views: 258 I see a problem from how the program should be running (although desired results would be nice to know...) it's in your do-while loop
Here's Dave's wonderfully simplified code:
#include... |
Forum: C++ May 28th, 2009 |
| Replies: 9 Views: 258 so, does that solve your problem or (since you never said what the problem was) is there more? |
Forum: C++ May 27th, 2009 |
| Replies: 10 Views: 532 touche ;)
to the OP: indenting your code also makes it easier to follow/read/understand/etc. |
Forum: C++ May 27th, 2009 |
| Replies: 10 Views: 532 code tags really help :)
std::cout << "k: " << k;
or it's really simple to run through that loop in your head... and if you understand what's going on it's even easier to know what the... |
Forum: C++ May 18th, 2009 |
| Replies: 10 Views: 617 thanks for the responses
I'll leave that one where it lies :)
As for the suggestions, adding the cpp file contents into the header worked perfectly, thank you. I guess I was too used... |