2,712 Posted Topics

Member Avatar for MilesN

Welcome, we'll be glad to help. Just make sure you read the rules, and use code tags and such.

Member Avatar for maceman
0
23
Member Avatar for sho12345

When you do this : [code] #include "sim.cpp" using namespace std; [/code] you are not including namespace std, inside sim.cpp, because of the ordering. Just do this : [CODE] #include <iostream> #include <fstream> #include <queue> #include <list> #include "ItemType.h" [COLOR="Red"]using namespace std;[/COLOR] [/CODE] yo

Member Avatar for sho12345
0
274
Member Avatar for evans007
Member Avatar for sgriffin

Your function prototype is constant corrected, so that means you cannot change the member variables, which you should not have to. First you need to check if both the matrix are of equal size( equal row AND equal column ). Then next, you should create a new matrix object, that …

Member Avatar for sgriffin
0
107
Member Avatar for Valter Henrique

Why create it when stl already has one for you? Maybe you should give more information on what you are trying to do.

Member Avatar for Valter Henrique
0
106
Member Avatar for mrnutty

The objective is to make it last long as possible. The rules is that I say ONE word, and another person has to say ONE word which will be a part of a sentence when more word comes. A sample run : [ICODE]Post# The word posted --------------------------------- 1 Hello 2 …

Member Avatar for maydhyam
0
109
Member Avatar for laehc

You should not worry about how fast a fundamental loop is. If you care about speed, then your bottleneck is probably elsewhere.

Member Avatar for laehc
0
164
Member Avatar for corby

>>[b]for i = 0 to n-1 do[/b] how long does this loop run for? >>[b]for j = 0 to (i^2) - 1 do[/b] Realize that this loop runs for (i^2)-1, for EACH i in the loop before this >>[b]for k = 0 to j - 1[/b] Realize that this loop …

Member Avatar for corby
0
108
Member Avatar for XAaronX

Usually one would use Vectors to store the positions. Like so : [code] struct Vector{ float posX; float posY; //.... } [/code] And if your Tree sprite class is something like this : [code] class Tree{ private : Vector position; //... } [/code] You would use composition inside your Tree …

Member Avatar for mrnutty
0
170
Member Avatar for merse

>>[b]Is it possible to do function overloading with different return type?[/b] No its not consider this situation : [code] void what(){ return /* nothing */ ; } bool what(){ return true; } int main(){ what(); //which function does this call ? } [/code] As you see, overloading functions with different …

Member Avatar for mrnutty
0
79
Member Avatar for eggberto

try something like this : [code] const int UPPER_LIMIT = 10; const int LOWER_LIMIT = 0; int chosenOne = 3; //within lower and upper limit int random = chosenOne; while(chosenOne == random){ random = randomNumber(LOWER_LIMIT,UPPER_LIMIT); } [/code] I'll let you define randomNumber(int,int) function.

Member Avatar for mrnutty
0
97
Member Avatar for sana zafar

First make a matrix class. Have it functional with the appropriate functions. Then open the file and read it into the matrix. Then solve it using the matrix class and its operations.

Member Avatar for mrnutty
0
119
Member Avatar for godsgift2dagame

wait, can you repeat your question 1 more time, in a more clear and less anxious manner.Thanks and btw, this [code] BigInt number1; BigInt number2(3484858); BigInt number3("89347893478349234045"); cout << number1 + number2 + number3 << endl;[/code] is possible.

Member Avatar for Banfa
0
126
Member Avatar for SacredFootball

Here is an example on how to grow vectors : [code] int main(){ std::vector<int> numbers; //input 10 numbers from user for(int i = 0; i < 10; ++i){ int input = 0; cin >> input; numbers.push_back( input ); } return 0; } [/code]

Member Avatar for VernonDozier
0
134
Member Avatar for LevyDee

Thats basically it. It divides the problem by 1/2 each time until it either finds a solution or is out of bounds.

Member Avatar for mrnutty
0
88
Member Avatar for SacredFootball

I think its hear : [code] cin >> userGuess; while (!cin >> userGuess) { [/code] In there you are asking the user to input a guess first. Then say it failed. Then in the while loop it goes to ask the user to input a number again. But the stream …

Member Avatar for mitrmkar
0
18K
Member Avatar for pedro2010

Would something like this work for you : [code] float cut(float num, int maxDigitsAllowedAfterDecimal){ //error checking if you want int wholePart = num; if(maxDigitsAllowedAfterDecimal == 0) return wholePart; float decimalPart = wholePart - num; long factor = pow(10,maxDigitAllowedAfterDecimal); return wholePart + float(( long((decimalPart*factor))/factor)); } [/code]

Member Avatar for mrnutty
0
98
Member Avatar for am5a03

[QUOTE=abhimanipal;1203041]Probably some thing of this sort [CODE=C] void rev(int* arr, int lower, int upper) { if ( lower >= upper) return; // Swap the 2 values rev(arr, lower+1, upper-1); } [/CODE] Where lower and upper are the smallest and the largest indexes of the array[/QUOTE] Where are you changing the …

Member Avatar for am5a03
0
231
Member Avatar for spacerat

>>well, the compiler fortunately didnt complain :-) No, in fact thats unfortunate. >>anyway, the advantage of this implementation over the next_permutation in STL is, that you can instantly get the permutation at any index. The disadvantages is that this is not a safe code. Its a homemade code, and is …

Member Avatar for chtulu
1
649
Member Avatar for mebob

>> for ( c = 0; c < 13; c++ ) should that 13 be 14 ? and go ahead and run the debug mode. It will give you more experience.

Member Avatar for mebob
0
161
Member Avatar for mattloto

You can use [URL="http://www.cplusplus.com/reference/algorithm/find/"] std::find[/URL]

Member Avatar for david.k
0
177
Member Avatar for naseerhaider

We can but not the way you showed it. [code] if ( (choice == 'e' || choice == 'E') && (cur == 'd' || cur == 'D' ) ){ //... } [/code]

Member Avatar for chiwawa10
0
135
Member Avatar for RayRay1

[QUOTE=VernonDozier;1200769]First thing that you need to do is write a driver program that has a main function in order to test it. Test the constructors and printRational. If you haven't written printRational, write it because you'll need it a lot when testing. [code] // driver program // includes int main …

Member Avatar for RayRay1
0
846
Member Avatar for mark88211

1st Create an array of 20 elements like so : [code] const int MAX_STUDENTS = 20; int Scores[MAX_STUDENTS] = {0}; //create and initialize all 20 elements to 0 [/code] next you need to ask the user to enter 20 integers. Using a for loop is a good idea. For example, …

Member Avatar for mrnutty
-3
125
Member Avatar for d34dw4rd

put a break statement inside all of the if statement. Why not combine all of the if statement and provide a generic error message, if the detailed message is not important?

Member Avatar for d34dw4rd
0
117
Member Avatar for rowley4

You can't define a function inside another function. Here is one way : [code] #include <iostream> void aFunction(int x, int y); //function prototype int main(){ aFunction(2,2); //function call }//end of main void aFunction(int x, int y){ //function header and definition cout << "(" << x << "," << y << …

Member Avatar for jonsca
0
135
Member Avatar for sidra 100

change this : [code] # include <iostream.h> # include <conio.h> main () [/code] to this : [code] #include <iostream> #include <string> using namespace std; int main () [/code] and instead of getch() use this : [code] cin.clear(); cin.ignore(256,'\n'); string pause; getline(cin,pause); [/code]

Member Avatar for mrnutty
0
92
Member Avatar for achieve_goals

Assuming you are setting it something like this : [code] class Node{ //... }; template<typename Type> class Queue{ //... }; int main(){ Queue<Node> queueNodes; } [/code] If not then post some code so it will be more clearer.

Member Avatar for mrnutty
0
91
Member Avatar for Pawello

First use arrays : Do something like this : [code]struct Poles{ Poles poles[8]; }; [/code] Next, your question : >>[B]I want to make a function which would use correct pole(pole1, pole2...pole8) depending on parametres[/B] I am not exactly sure what you mean, so before I give you a answer, you …

Member Avatar for mrnutty
0
115
Member Avatar for bobmckinely

Well this is essentially a transversal problem. You need to verify that the left child of the parent is less than, and the right child of the parent has to be greater than the parent. So essentially you will have to transverse the whole binary tree. Whats the usual transversal, …

Member Avatar for prime1999
0
417
Member Avatar for #define

Real Numbers are uncountable, so you can't list all of the numbers. A proof for this is usually, done by the [URL="http://en.wikipedia.org/wiki/Cantor's_diagonal_argument"]Cantor's_diagonal_argument[/URL].

Member Avatar for jwenting
0
159
Member Avatar for Kevin_160

Change your pre-processors to this : [code] #include <fstream> #include <string> using namespace std; [/code] The main thing you forgot was the using namespace std, in your code.

Member Avatar for mrnutty
0
2K
Member Avatar for dawn.visp
Member Avatar for Johnsmith1
0
96
Member Avatar for restrictment

Thats because you are doing int arithmatic. Basically : 130/3 = 43 130.0/3.0 = 43.333333... So to solve your problem, and to be safe, put a .0 at the end of each numbers. So in total it will look like this : [code] average = float(100.0-((25.0/(130.0-(50.0-(130.0/3.0))))*100.0) ); [/code] The float(...) …

Member Avatar for restrictment
0
92
Member Avatar for VilePlecenta
Member Avatar for Hidden_mistakes

>> I am trying to move a player in direction angle by speed I am kind of hesitant of what you mean exactly by that, can you explain?

Member Avatar for Tigran
0
122
Member Avatar for Tops

Trace it out. 1) [code] //returns 2 times the number passed in def T2(x): return x * 2 [/code] 2) [code] //return T2(12) = 12*2 = 24 def dozen(): return T2('12') [/code] 3) [code] //returns T2(3) = 2*3 = 6 def enestrate(): return T2(3) [/code] now this call : [code] …

Member Avatar for BestJewSinceJC
0
127
Member Avatar for trantran

Yes its permitted. 1st of all why do you need to use it? Second, the syntax gets pretty tricky. Here is an example : [code] #include <iostream> using namespace std; struct Foo{ int x; int y; void print(){ cout << "(" << x << "," << y << ")" << …

Member Avatar for trantran
0
122
Member Avatar for RehabReda

Simulating the heart or something medical? A graphical tour of your school ? Google?

Member Avatar for jwenting
0
89
Member Avatar for Hatem Faheem

what you are looking for are more along the lines of this : [code] void populateUniqueRandom(int Array[], const int size, int start, int end){ assert(end-start == size); //make sure the size the correct size for(int i = 0; i < size; ++i){ Array[i] = end - start + i; } …

Member Avatar for VernonDozier
0
116
Member Avatar for Hidden_mistakes

If you are on windows, then you can use [URL="http://msdn.microsoft.com/en-us/library/aa909766.aspx"] PlaySound [/URL]. If not then there might be something similar to your OS. If all fails, you will have to use a 3rd party library.

Member Avatar for Hidden_mistakes
0
295
Member Avatar for NathanOliver

Another thing to add, I feel like you have a lot of redundant coding. For example, you can implement the operator -() in terms of the operator +(), instead of providing a definition for each one. Did you feel like you have copied and pasted a lot of code?

Member Avatar for NathanOliver
0
151
Member Avatar for ppotter3

When you say it crashes, when does it crash? Do you know at what line? Also the cipher you are doing is called ceaser shift cipher. If you would like to wrap a encoded char to be within 32-126, then use the modulus operator, although your method looks like it …

Member Avatar for ppotter3
0
2K
Member Avatar for thehivetyrant

>>I'm attempting to make it register when i move a sphere beyond it's x,y,z position. I am confused by this statement. Can you clarify a what you mean? Also can you clarify what exactly your problem is. Sorry I couldn't understand what you were trying to say.

Member Avatar for thehivetyrant
0
216
Member Avatar for thehivetyrant
Member Avatar for thriek

You will have to work with the graphical window, because once you exit the sdl window, it automatically closes the console window as well. You might be able to get around this by using win32 but thats another language you will have to learn.

Member Avatar for thriek
0
411
Member Avatar for eggberto

No you use what someone geniuses already have written for you. It will be pretty hard to create your own graphics command, that does not encapsulates other's functions. I would suggest to start with SDL. [URL="http://lazyfoo.net/SDL_tutorials/index.php"]This[/URL] link will be a good start.

Member Avatar for WaltP
1
313
Member Avatar for warlock07

Just an idea, since the array is ordered. Consider comparing the mid of the array. If the number X is greater than the mid, then compare the mid of the top half. Keep this pattern. As soon as you have failed 2 greater than comparison, then start with the subList …

Member Avatar for warlock07
0
208
Member Avatar for thehivetyrant

>>i have this rectangle and i want to be able to rotate this shape around another when i press a key. By default the rectangle rotates around the origin. So if you wan't the rectangle to rotate around an object, then translate the world x units until the object to …

Member Avatar for thehivetyrant
0
1K
Member Avatar for LostnC

[QUOTE=LostnC;1188160]Hello everyone, I am trying to understand composition versus inheritance in C++. I have looked at many web pages, but I haven't found anything that makes sense to me. Can someone please tell me where I can find some examples of programs that might make sense to me? I am …

Member Avatar for mrnutty
0
206

The End.