You definitely need to rethink your usage of classes - that's not how they were meant to be used. They are supposed to represent (conceptual) object classes and thus the instances should represent certain objects.

But: what is a "dead"? And what is an "alive"?

There is no difference, except that you connect to the remote IP address instead of your own.

What do you have so far?

The error message says it all.
ApplyRoll expects seven arguments, but you're just passing one.

Looks okay at first glance, except for a few issues:

  1. No const-correctness. Member functions that do not change the object (size, empty) should be const.
  2. new does not return a null pointer when there is no more memory - it throws an exception of type std::bad_alloc.
  3. What's the deal with the full function? You're leaking memory all over the place for every call to it.
  4. Same in pop() - there are several "new"s in the program, but not a single "delete".
  5. top() should throw an exception if the stack is empty instead of rudely exiting the program.
  6. Missing braces in top() - the function will always cause the program to exit.

Code in the form [ICODE]if (foo)return true; else return false;[/ICODE] can be shortened to [ICODE]return foo;[/ICODE]
So in the case of empty() this is sufficient:
[CODE]bool empty() const {return !front;}[/CODE]

By the way, I don't see any use of the STL here.
The STL has a stack class already (std::stack).

[QUOTE]but im not using numbers or vectors im using strings and arrays look ill post the question it might be helpful [/QUOTE]
What difference does that make? std::sort isn't restricted to vectors or numbers.

The code line I posted is the "code outline".
I'm talking about this sort:

This assignment sounds very familiar...
anyway, why do you think you need to change the function?
std::string overloads operators <, == and >, so it should work without any changes.

Do you have to implement the sorting algorithm yourself?
If not, a
does the trick (needs the header algorithm).

Hm, sure doesn't look much like selection sort...
I particularly don't get what the checks for -1 are supposed to do and what ptrinput is for.

Selection sort can be done simpler and in-place (i.e. without an extra array):



using namespace std;

int main()
int numberCount;
cout << "How many numbers to sort? ";
cin >> numberCount;

vector input(numberCount);
for (int i=0;i<numberCount;i++)
cout << "Enter number #" << i+1 << ": ";
cin >> input[i];

for (int i=0;i<numberCount;i++)
int bestIndex=i;
for (int j=i+1;j<numberCount;j++)
if (input[j]<input[bestIndex])bestIndex=j;

cout << endl << endl << "Final result:" << endl << "----------------------" << endl;
for (int i=0;i<numberCount;i++)cout << input[i] << endl;

tundra010 commented: +1 +2

This should be in Hardware Software/Linux and Unix/Getting Started.
Most Windows programs run fine when you have Wine installed. However, some show problems that are not present when running on Windows and some don't work at all.
See the Wine AppDB entry for your software (assuming it's what you mean):

Seems like it runs okay.

Perhaps you should explain the sorting algorithm you had in mind, because it isn't really obvious.

In the meantime, I have lots of comments about the code:
Line 7-9: Make sure to use descriptive variable names. A proper name for "a" could be arraySize or numberCount. b and temp aren't needed, because...
Line 15-16, 26-27: can input a number directly without using a string (cin >> a)
Line 8-9; No need to initialize string explicitly with an empty string literal, string b; does the trick
Line 19-20: The array size must be a constant known at compile-time, so this is not valid standard C++. Replace this by vector input(a); (same for sorted) - you need to include the vector header for this.

In various lines: don't use NULL for integrals, that's confusing. NULL is just a define for 0 - and if you use NULL at all, it should only be used to indicate a null pointer.

For the MSS problem you build the sum of the most left subsequence then keep advancing through the main sequence by subtracting the most left element of the subsequence from the sum and adding the next element right after the subsequence.
So that's similar to the method I suggested for the rectangle.
If you can think of a more efficient method, go ahead. There's nothing that can be in a better class than O(n²), though (assuming n is the side length of the source square).

[QUOTE=AuburnMathTutor;1292153]Are you sure you'll have to check every rectangle? That's not obvious to me, especially given the fact that you can do better than that on the maximum subsequence sum problem, to which this seems related.[/QUOTE]
No, you can't do better on the maximum subsequence sum problem, because you have to [i]look at every value[/i].
I don't think you read my post properly.

You'll have to test every possible subrectangle, however you can start at the top-left and keep going left, so you can subtract the most left column of the subrectangle and add the new column each step. When you're done with the row, start with the next one.

You should have received login info for your server when you purchased it.
If the server runs Linux, you can login to a remote shell via SSH.
If it runs Windows, I believe the "remote desktop" tool is the preferred way to access your server.

To copy files on your server (Linux), use scp/WinSCP or mount the server's file system directly.
I'm sure there are simple ways to copy files remotely on a Windows server too. If in question, just upload your program somewhere and download it on the server.

The easiest way to do this is to write a program that takes a problem as the input and gives the source code of the solution... then you can use it to solve this problem.

Seriously though, what kind of algorithm? Don't say "any"!

[QUOTE]And yes, it can be greater than the sum of the two other sides, that's the only way it can be a triangle. [/QUOTE]
Since you seem to know it better, I guess you shouldn't need any help on this...
but I'll give you three points to think about:
A(0|0|0) B(0|1|0) C(1|0|0)
a) do they form a triangle?
b) if so, what are the lengths of its sides and the ratio to the sum of the other sides?

Well. If the points are colinear, then one "side" equals the sum of the other two.
I don't think it is ever possible that the long side is [i]greater[/i], so the function will always return 0. If you subtract the delta value instead of adding it you're handling the case that both operands are equal correctly - still, when the condition is fulfilled, it's not a triangle and you need to return false (not true/1).
[CODE]return !(side1 > side2 + side3 - 0.00000001 || side2 > side3 + side1 - 0.00000001 || side3 > side1 + side2 - 0.00000001);[/CODE]

The return type of triangle_test is still wrong, by the way. It should be bool.

[QUOTE="mike_2000_17"]This can be a divide-by-zero. [/QUOTE]
True. The line before that was supposed to prevent this, but I realized it doesn't.
Calculating the cross-product would be more straight-forward, but apparently the OP isn't allowed to use alternative methods anyway.

Try to do it when compiling with -pedantic-errors.
As for the corresponding part of the C++ standard:
QUOTE Recursive calls are permitted, except to the function named main (3.6.1).[/QUOTE]

You can have more than one loop per program, you know.
You don't need goto.

[code]int main()
for (;;)
{ //main loop
for (;;)
{ //user input loop
switch (userinput)

Calling main results in undefined behaviour, so not really.

jonsca commented: Agreed +4


You can't just listen on a foreign IP address - the address must be one of your own network addresses, i.e. one that your computer is connected to the network with.
If you use say, an address of a Google server, it won't do you much good: the internet routers will route all packets to the Google server, but never to you. Same for the webhost service - the messages will always be sent to the webhost server.
So in order for this to work, your program needs to run on [i]their[/i] server. You can simply rent one (virtual servers are usually quite cheap) or you can be the server yourself - then you'll need to connect to your own IP address. If you have a router, you'll probably need to add a port forwarding rule.

boost is a library that provides a lot of frequently needed functionality.
As you can see, boost has numerous sub-libraries:

Math/Special Functions is the one you need in this case.
To install boost, refer to the installation guide on the boost site.

erf and erfc were added to C with the C99 standard, but Visual C++ still doesn't support it.
I suggest you install boost if you don't want to switch compilers.

Boost.Math provides an implementation of erf and erfc:

[QUOTE]or do I have to, in this kind of situation? Does the function free the memory automatically when the return statement is met?[/QUOTE]
No delete - no deletion. It would be pretty bad if the memory was freed anyway - then you'd return a pointer to a destroyed object.

But yes, it does leak - you have no delete anywhere. You need to delete paramTime after you're done with it.

Besides, returning a pointer to an object created inside the function is very bad style due to the high risk of memory leaks if you forget to delete the returned object. There are some possible solutions to this (for all it is implied that you don't return a pointer, but an object):

1) If the object can have an invalid state, return an invalid object on failure. A time class could - the invalid state could be zero for each member. An isValid() member function can be used to check for validity.
2) throw an exception if the function fails.
3) assign the time to an object passed by reference and return whether the function was successful.
4) keep using new but return a smart pointer such as auto_ptr, unique_ptr or shared_ptr.

This is far and well beyond your abilities. But if you're willing to learn, you can start here:

You're having it the wrong way around: your function says it's a triangle when it's not and says it's not a triangle when it is.

Ah, you're right, of course. The first part of my sentence doesn't fit with the second.


aType is neither an English word nor a C++ keyword.