Forum: C++ 22 Days Ago |
| Replies: 3 Views: 230 Objects in C++ can't change their type. You can have a variable of some pointer-to-animal type and then assign a new pointer-to-animal to that variable though. |
Forum: C++ Nov 9th, 2009 |
| Replies: 1 Views: 202 Just remove a letter from the first string, print that letter, and do a recursive call. Of course, you'll want to do this for each letter. |
Forum: C++ Nov 5th, 2009 |
| Replies: 7 Views: 682 Your problem is that you're writing very complicated and redundant code and thus it's hard to think about what your code is doing. Use a simpler algorithm to find and remove the largest and smallest... |
Forum: C++ Oct 23rd, 2009 |
| Replies: 6 Views: 279 It doesn't matter. Do what you enjoy. It's not like it's hard to learn a new language later. Realize that you'll have to mostly teach yourself C++ if you really want to learn it, because your... |
Forum: C++ Oct 23rd, 2009 |
| Replies: 1 Views: 131 |
Forum: C++ Oct 22nd, 2009 |
| Replies: 4 Views: 226 No, next_permutation won't work because his desired output is out of order :)
Hope this helps :)
#include <stdio.h>
int main(void) {
puts("123");
puts("132");
puts("213");
... |
Forum: C++ Oct 21st, 2009 |
| Replies: 8 Views: 636 The U means that it's an unsigned integer literal. size_t is an unsigned integer type that's guaranteed to be able to hold the size of an array. But not a std::string. If you're paranoid you... |
Forum: C++ Oct 21st, 2009 |
| Replies: 8 Views: 636 Is your call to .length() getting called every time or are you assuming that will get optimized away? |
Forum: C++ Oct 21st, 2009 |
| Replies: 4 Views: 689 Don't use any globals (i.e. static variables) and have your function that calculates the answer be separate from the function that prints the answer. |
Forum: C++ Oct 11th, 2009 |
| Replies: 3 Views: 411 Uh, I meant double tsurface = tsurfaceFUNCTION(radius, height, PI); of course. |
Forum: C++ Oct 11th, 2009 |
| Replies: 3 Views: 411 Your syntax is invalid. You're using the syntax for declaring a function, when you should be using the syntax for calling a function:
double tsurface = tsurfaceFUNCTION(radius, height, double... |
Forum: C++ Oct 8th, 2009 |
| Replies: 9 Views: 832 Huh? I didn't insert any tags. |
Forum: C++ Oct 8th, 2009 |
| Replies: 9 Views: 832 I was asking a yes or no question, and a simple "no" would have sufficed :P |
Forum: C++ Oct 8th, 2009 |
| Replies: 9 Views: 832 What? Are you mentally retarded? |
Forum: C++ Oct 8th, 2009 |
| Replies: 9 Views: 832 Just use vector<>. Never use arrays. I mean, sure, at some point in time, you'll want to learn how to use them. They are useful for implementing vectors, after all. And sometimes, occasionally,... |
Forum: C++ Oct 8th, 2009 |
| Replies: 4 Views: 274 atoi(text[0]) will not work because atoi expects a char*, not a char. That half of NeoKyrgyz's answer was basically useless and dumb.
If you want to convert the character "c" representing the... |
Forum: C++ Sep 26th, 2009 |
| Replies: 13 Views: 459 Try figuring it out yourself. Then maybe you'll learn something. |
Forum: C++ Sep 25th, 2009 |
| Replies: 13 Views: 459 Why don't you keep track of how many values the user has entered, and use some mechanism to see if that number's 10? |
Forum: C++ Mar 14th, 2009 |
| Replies: 22 Views: 1,536 What? Why did you suddenly start using C? |
Forum: C++ Mar 13th, 2009 |
| Replies: 22 Views: 1,536 Do you understand how arrays work? |
Forum: C++ Mar 13th, 2009 |
| Replies: 22 Views: 1,536 If I were you, I would regard each of your details, 1, 2, and 4, as an individual problem to write a function for. Then the program is a simple combination of these functions, meeting detail 3. |
Forum: C++ Mar 13th, 2009 |
| Replies: 22 Views: 1,536 You could start with a function that gets the input from the user. |
Forum: C++ Mar 13th, 2009 |
| Replies: 10 Views: 682 You want to calculate the n-term series and not the infinite series? |
Forum: C++ Mar 13th, 2009 |
| Replies: 22 Views: 1,536 |
Forum: C++ Mar 13th, 2009 |
| Replies: 14 Views: 798 Your "line equation" is wrong -- you have defined a point. |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 682 In that case, the right solution would still be to use the closed form expression :) |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 682 Well it's almost like the series for exp(x), except the signs are alternating and it's missing the x^1 term and the x^0 term has the wrong sign. If consider the series you get for exp(-x), you... |
Forum: C++ Mar 12th, 2009 |
| Replies: 17 Views: 672 I assumed you would have no problem spotting the errors, but alas, some are still unnoticed. |
Forum: C++ Mar 11th, 2009 |
| Replies: 2 Views: 400 You need some way to convert strings to ints. One way is to use a stringstream, another way, after verifying that all characters of the string are digits and that there is one or more of them, is to... |
Forum: C++ Mar 11th, 2009 |
| Replies: 17 Views: 672 |
Forum: C++ Mar 10th, 2009 |
| Replies: 5 Views: 668 It is so polymorphism. The derived class can override the base class's behavior in other ways than just virtual functions. |
Forum: C++ Mar 10th, 2009 |
| Replies: 5 Views: 668 What are you asking? Are you confused about the operational semantics of C++, or are you asking about terminology? |
Forum: C++ Mar 10th, 2009 |
| Replies: 1 Views: 403 You want a struct with a double and a bool.
You should never use inheritance except as a mechanism for polymorphism -- one reason being that 'putting stuff into structs' or classes (a.k.a.... |
Forum: C++ Mar 9th, 2009 |
| Replies: 10 Views: 606 I typed up a long reply to you before but decided to save it. One thing I think that is horrible with your notation is your use of functions like isnz, ife, etc etc. Ultimately they're insufficient... |
Forum: C++ Mar 7th, 2009 |
| Replies: 6 Views: 303 Oh, it's just looking for a main function to run.
http://codepad.org/teq2fuVp
It seems to work fine. You have an implementation of Vector, right? |
Forum: C++ Mar 7th, 2009 |
| Replies: 6 Views: 303 No, the answer is not that you're designing anything wrong. There is nothing wrong at all about mutually recursive data datatype definitions. There are inconveniences involved with circular data... |
Forum: C++ Mar 7th, 2009 |
| Replies: 10 Views: 606 |
Forum: C++ Mar 7th, 2009 |
| Replies: 10 Views: 606 Just by reading the code and looking at what it does. |
Forum: C++ Mar 6th, 2009 |
| Replies: 5 Views: 447 Don't ask us, ask your teacher. |
Forum: C++ Mar 6th, 2009 |
| Replies: 10 Views: 606 It is possible to convert C++ code to mathematical expressions. And it's basically straightforward. I think your scheme for this is fairly straightforward, except that you seem to write the +... |