Forum: C++ Sep 30th, 2009 |
| Replies: 4 Views: 395 I'm not sure what your problem is, when I compile and run it:
start
Caught One! Ex. #: 1
Caught One! Ex. #: 2
Caught a string: Value is zero
Caught One! Ex. #: 3
end |
Forum: C++ Jul 29th, 2009 |
| Replies: 2 Views: 160 It looks like it compiled, so the symbol was defined enough for the compiler to recognize them.
The link process is where the actual executable is built. The linker needs to match up the symbol... |
Forum: C++ Mar 6th, 2009 |
| Replies: 4 Views: 1,127 const is a 'promise' not to change.
If you have member-functions that do not change your class (and never should) you can declare them const.
const member-functions are declared like this:
... |
Forum: C++ Mar 6th, 2009 |
| Replies: 10 Views: 593 @VernonDozier
You're right (again), I missed the fact that they would all be 3's to start.
Not that it is an excuse, but my convention for TTT win checks is to check for matches against the last... |
Forum: C++ Mar 6th, 2009 |
| Replies: 10 Views: 593 It would appear that inside move, placement is actually getting set to true when the game is 'won' but nothing is looking at placement to stop the game. The only stop case is when the board is full. |
Forum: C++ Mar 6th, 2009 |
| Replies: 10 Views: 593 Oh, and please:
When posting c++ code, please use c++ code tags
// Your code here |
Forum: C++ Mar 6th, 2009 |
| Replies: 10 Views: 593 Actually, it should never get to that print line...it returns from inside all over the function. (Though I'm not sure that the returns in all of the test are required.)
Is the board required to be... |
Forum: C++ Mar 2nd, 2009 |
| Replies: 2 Views: 244 Where is the declaration of com_num in relation to the order function? com_num needs to be visible to any compile target that can see order.
What specifically is the compiler error?
Which is... |
Forum: C++ Feb 21st, 2009 |
| Replies: 14 Views: 855 Please when posting to these forums, wrap your code in code tags (like daviddoria did above).
Use either:
...
or
...
The second form provides for syntax highlighting and line numbers. |
Forum: C++ Feb 21st, 2009 |
| Replies: 6 Views: 788 If you don't intend to use any of the predefined C++ data types in your implementation, what do you propose to use?
A 6000 byte long number could be implemented, I would probably use an array with... |
Forum: C++ Jan 31st, 2009 |
| Replies: 16 Views: 1,242 Thanks for using tags, but your formatting could still use some work :)
If you use tags, the code will have line numbers and syntax highlighting.
The first section trying to validate input:
... |
Forum: C++ Jan 26th, 2009 |
| Replies: 16 Views: 1,069 That's still pretty painful to look at, maybe if your code tag worked (use [code=c++] to start it (no spaces in the tag).
You have a for loop that i think was supposed to be closed, but was not:
... |
Forum: C++ Jan 25th, 2009 |
| Replies: 12 Views: 633 You already have a 'global' (ok so it is local to the class, but all of the class methods can see it) data area defined. See this section under private in your class:
private:
double average;... |
Forum: C++ Jan 25th, 2009 |
| Replies: 12 Views: 633 When you run the code, are you still having to put the grades in 4 times or did you fix that?
Could you post your new code? |
Forum: C++ Jan 25th, 2009 |
| Replies: 20 Views: 913 Quoting ... again:
You appear to have the same code in elapsed. You initialize duration to zero, compare it to t1 and t2 without doing anything with either value and return.
Perform the... |
Forum: C++ Jan 24th, 2009 |
| Replies: 20 Views: 913 Why are you trying to re-declare h inside the if statement?
if ( int h > 10)
should be:
if (h > 10) |
Forum: C++ Jan 24th, 2009 |
| Replies: 3 Views: 288 Once you have both of those, you can use the two numbers to calculate the total weight of the widgets.
And if you know how much all the widgets weigh and how much a single widget weighs (and at... |
Forum: C++ Jan 24th, 2009 |
| Replies: 12 Views: 633 Your class has space for 4 class names and 4 grades.
But when you accept input from the user, you read a class name and then 4 grades for that class.
Then you read the next class name and 4... |
Forum: C++ Jan 24th, 2009 |
| Replies: 20 Views: 913 ok you could make that work, but you forgot to print the m and h...and you should probably print the hours first.
if (h > 10) {
cout << h;
} else {
cout << '0' << h;
} |
Forum: C++ Jan 23rd, 2009 |
| Replies: 20 Views: 913 No.
h ends up zero and m ends up being whatever h was * 60
Now that I think about it, why does display1Time even need h and m, aren't the hours and minutes in Mytime?
The tens and ones hint... |
Forum: C++ Jan 22nd, 2009 |
| Replies: 20 Views: 913 Line 58: else if (m > 60) should compare m > 59
You have made no additional effort on display1Time() or elapsed() and I have already given you suggestions for those:
and |
Forum: C++ Jan 22nd, 2009 |
| Replies: 7 Views: 1,499 There's no real difference in how the symbol is treated other than the fact that the compiler would allow you to modify argv in the second example. (Not that modifying argv is a good idea.)
The... |
Forum: C++ Jan 22nd, 2009 |
| Replies: 20 Views: 913 You were right about his number, but that's not really C++, that's just basic logic. You could understand that and correct it. (And just to back you up, if you had posted that code, I would have said... |
Forum: C++ Jan 22nd, 2009 |
| Replies: 10 Views: 1,286 Ok, so I have the values 0,1,2,3,4,5,6,7,8,9,10 in those positions in the input array...
You caclulate mid as (low + high) /2 so the first mid is 5?
we put 5 at the root and iterate left with... |
Forum: C++ Jan 22nd, 2009 |
| Replies: 10 Views: 1,286 Ok, so what kind of tree does it build?
How is it sub-optimal?
What would you have to change to make it optimal? |
Forum: C++ Jan 22nd, 2009 |
| Replies: 10 Views: 1,286 I'd like to experiment with the code to try it, but in the interest of a quick answer, try low < mid on line 20 and mid < high on line 25.
Basic translation: If there are values between low and... |
Forum: C++ Jan 21st, 2009 |
| Replies: 20 Views: 913 It doesn't really matter which side of the comment is on, comments are for us to read, the compiler doesn't care.
Your code
if (h < 0)
{
return 1; // error code +1 = underflow hours
}
else... |
Forum: C++ Jan 21st, 2009 |
| Replies: 20 Views: 913 As we stated in your previous thread, we will help you if you put in some effort, but we don't solve your problems for you.
When posting c++ code, please use c++ code tags
// Your code here
... |
Forum: C++ Jan 21st, 2009 |
| Replies: 9 Views: 319 To help me and you think about it, write down in english what you think the compare function should be doing.
It will help me to understand what you intended and whether or not it will accomplish... |
Forum: C++ Jan 20th, 2009 |
| Replies: 8 Views: 445 Are you sure the link to test1.cpp is the right file?
It is calling members of Logbook that are not defined in logbook.h and if I understand correctly, both files were given and you're not... |
Forum: C++ Jan 20th, 2009 |
| Replies: 5 Views: 273 When posting c++ code, please use c++ code tags
// Your code here
Don't try to print answer on the 'please enter in two numbers' lines. |
Forum: C++ Jan 20th, 2009 |
| Replies: 14 Views: 760 Once you 'know' what class it actually is, you can cast the pointer...
if (typeid(*pacct) == typeid(SavingsAccount)) {
SavingsAccount * pSave = (SavingsAccount *)pacct;
// or more... |
Forum: C++ Jan 20th, 2009 |
| Replies: 14 Views: 760 In your code, an "Account *" will never be a "SavingsAccount" you are directly comparing two types. You wanted to compare an instance and a type. The following worked for me:
if (typeid(*pacct)... |
Forum: C++ Jan 19th, 2009 |
| Replies: 18 Views: 2,582 That first '0' you're seeing almost looks like unresolved input.
Your menu selection only reads a character from cin, if you have to hit a return before the menu option is selected, the return may... |
Forum: C++ Jan 19th, 2009 |
| Replies: 18 Views: 2,582 (I'm just slow I guess...but here it is anyway)
You can't just cast a character pointer (that is what inputVal.c_str() returns) to an int and expect to get the integer value represented by the... |
Forum: C++ Jan 19th, 2009 |
| Replies: 14 Views: 760 I was able to get the vector to work and support the polymorphism:
vector<Account *> accounts;
accounts.push_back(new SavingsAccount(25.00, 1.00));
accounts.push_back(new... |
Forum: C++ Jan 19th, 2009 |
| Replies: 18 Views: 2,582 Add some debug...
Does list[cnt] = (int)inputVal.c_str(); get you the numeric value you entered, or the address of the string? |
Forum: C++ Jan 19th, 2009 |
| Replies: 18 Views: 2,582 The counter and the array were both declared inside the sample code (calcList), they wouldn't be visible outside of it. |
Forum: C++ Jan 18th, 2009 |
| Replies: 26 Views: 1,106 I'm not sure why you're getting the stream errors, I'm using Visual C++ Express and I'm not seeing the compile errors.
Are you mixing options for char and wchar_t somewhere? |
Forum: C++ Jan 18th, 2009 |
| Replies: 26 Views: 1,106 I suspect your problem with multiple inheritance is actually a multiple-include problem.
If you put Freaky_Chris's example in one file, you have no problem.
If you put all 3 classes into... |