466 Posted Topics
Re: Dude! This is an EIGHT-YEAR-OLD thread! You should probably start a new thread for your question :0) | |
Re: You almost certainly don't need to make anything a friend of anything else to do whatever it is that you're trying to do. Post the code that you have so far and we can have a better look at it... | |
Re: Also, this doesn't appear to be C++... | |
Re: Your algorithm will recurse on line 34, adding a new element to `combination` until it contains {0, 1, 2, 3}, since that's the size of `S`. On the recursion after the 3 is added, `last`, on line 29, will contain the final element of `combination` (3). On line 30 you … | |
Re: Is this a question? The code that you have will indeed check if the file exists or not. To write to a file, you'd need a `std::ofstream`, but that's the only difference. | |
Re: You have the indices swapped when accessing the elements of `temp` in the functions `hitemp` and `lowtemp`. You have: temp[ HIGH ][ i ]; you should have: temp[ i ][ HIGH ]; You could try making a `Range` structure and keep an array of those instead: struct Range { double … | |
Re: > Also try using at the top: > #define Socks 15 #define Underwear 10 #define Glasses 5 ...instead for all your items. Then you can perform mathmatical functions on them Don't do this. It's fine to do maths on `char` values (as long as you don't assign a value that … | |
Re: From [cplusplus.com:](http://www.cplusplus.com/reference/utility/pair/) > The header <utility> also overloads the relational operators ==, <, !=, >, >= and <= , so as to be able to compare pair objects of the same type directly: > Two pair objects are compared equal if the first elements in both objects compare equal to … | |
Re: I don't think that you use any of the functions from `conio` in this code, you should be able to just delete the line that includes it. Also, you have an issue with the curly braces in your code. All your functions are effectively defined *inside* `main`, which is not … | |
Re: The point of inheritance is that you *don't* need to do this. The question of which version of `toString` to call is decided at run-time. That's the point of `virtual` functions. So, consider this example: #include <iostream> #include <vector> class A { public : virtual void Print() const { std::cout … | |
Re: You just have a misplaced bracket. You have this: list.erase(std::unique(list.begin(), list.end(), list.end())); It should be this list.erase(std::unique(list.begin(), list.end()), list.end()); Did you spot the difference :) I think you get this compilation error because, in your version, the compiler is trying to use `list.end()` as a comparator (and it expects the … | |
Re: `execl` is designed to exit your process and start a new one. I've never used it though. Try reading [this](http://geoffgarside.co.uk/2009/08/28/using-execve-for-the-first-time/), it looks like it has some useful information in it. | |
Re: There's a sticky post at the top of the C++ forum on "flushing the input stream", it should help you understand what's going on here. On another note, I don't understand how you don't just see the "No such type of account" message every time you run the program. You … | |
Re: You might have to give a little more detail here. For example, what is a "ttf word form"? | |
Re: I think that boost will do all of these, except the database handling. For that you could use a specific library (although I don't have any suggestions). You could also think about using Qt, it has cross-platfom support for all the things you mentioned. | |
Re: As Ancient Dragon says, you should just try it an see. On a related note, you can concatenate multiple C-strings like this: #include <iostream> int main() { char s[] = "Hello" ", " "World!"; std::cout << s << std::endl; return 0; } I don't know when it's useful, but you … | |
Re: *How* is it not working? Does it compile? Does it crash? Does it produce the wrong result? What errors are produced? | |
Re: Yeah... this site doesn't really work like that. Did you read [the notes](http://www.daniweb.com/software-development/cpp/threads/78223/read-this-before-posting-a-question) before posting? Write some code and someone will help you fix/understand the errors. Generally, no-one's going to just striaght-up do your homework for you. You have to show some effort first. | |
Re: In this case the asterisk indicates that the variable returned by the function is a *pointer*. Google "C++ pointer" for more informaiton. Basically, it indicates a memory address where information of some sort can be found. A `static` member function is one that can be called without needing an instance … | |
Re: The asterisk in this context always means a pointer to something. It turns out that the "something" can also be a pointer. So, `char **argv` means that `argv` is a pointer to a pointer to a `char`. The reason for this is that each command-line argument is read in as … | |
Re: You will have an infinite loop in this program if you ask for any line that isn't "javad" and that line is found in the file. You should have another call to `getline` inside the inner `do{ ... }while` loop. Somewhere between line 21 and line 25. If you want … | |
Re: >But why does the video tutorial use iostream and works for him? You need to use both `<iostream>` and `<string>` to get this to work. The way C++ works, if one of the headers that you include also includes another header, then that header will also be included. It's almost … | |
Re: Er, where is C++ involved in this? | |
Re: Are you using a `std::string`? If so, you can use a combination of the `find` and `erase` methods: std::string s( "The quick brown fox jumps over the lazy dog" ); std::cout << s << std::endl; std::string::size_type position = s.find( "jumps" ); s.erase( position, 6 ); // Use a size of … | |
Re: If you don't want to use `std::string` for some reason, then you could use a `std::vector< char >`, or something like that. Or, you could make your own, simple `struct` for keeping a pointer to an array of `char` and a size: struct StringWithNulls { char* chars; unsigned size; }; … | |
Re: I don't think that you're going to find someone on here that is going to post you a complete set of solutions. Maybe you could post what you have of the third solution (which you implied you have started, but got stuck) and we could help you with that one? | |
Re: If the time taken to allocate a your vector/array is the main time cost in your program, then you're doing well! In reality, I would almost *always* use `std::vector` You could end up saving space. For example, if you make an array of 10000 `int`s then as soon as the … | |
Re: The of syntax `temp_m.EZ_MATH::EZ_GE_BY_ME();` looks very strange, maybe you could post more of the program for context? For example: * what type is `temp_m`? * What is the code in the function `EZ_MATH::EZ_GE_BY_ME`? | |
Re: > I'm not sure if I am doing the functions correctly. Is there anything I need to change? You're not and there is. Consider the `GetPlayer` function: int GetPlayer(PlayerInfo[]) { PlayerInfo playerid = {20}; PlayerInfo firstname = {20}; PlayerInfo lastname = {20}; cin >> playerid >> firstname >> lastname; return … | |
Re: Your function `return`s on line 7. However, `n` isn't incremented until line 9, which will never be exectued (since the function will have returned by this point). Move the `n++;` line before the `return word;` line. | |
Re: > Is there any problem to not define a constructor, but using an object to just access to those methods? No, if you don't provide a constructor the compiler will provide some basic ones for you. If you're only going to declare a class so you can use methods in … | |
Re: Your `Square` class inherits from `Rectangle` and sets the values for the side lengths of the rectagle class in it's constructor, but not its own `lSide` variable. You have also re-implemented the functions for the `Shape` interface in the `Square` class, which you don't need to, since their implementation is … | |
OK, so I'm mainly a C++ developer but I've been looking into making apps for Android. I haven't used Java before, or done much UI development, so it's a lot to take in at the moment. **There is a question at the end of this, skip to it if you … | |
Re: Er, you seem to have posted this four times?? There's no "built-in" way to do this in C++, you will have to write a program to do it. Start by looking up "numerical integration" on the internet and trying to make a program to do the things that you find … | |
Re: > Shouldn't you write line 2 with the length and currentPos variables inside it? No, it's fine the way it is. The variables `length` and `currentPos` are member variables of the `List` class so they are available for use inside all non-static member functions of the `List` class. In this … | |
Re: Your problem is line 9 (in your snippet). The expression FindDepBal(BalDep); doesn't make sense. You can only use this notation when *constructing* a `double`. So, for example, you could do double FindDepBal( BalDep ); // Construct with value or FindDepBal = BalDep; // Assign new value The way you currently … | |
Re: The first message tells you what the problem is. Look at line 214. It says it's expecting a ';' before the ')'. Is there a ';' everywhere you'd expect a ';'? | |
Re: Check the logic you use for calculating the indices on lines 12 and 14 | |
Re: If you're *absolutely required* to use a `reverse_iterator`, it's possible to construct a `reverse_iterator` to an array pointer and use that as you would any other `reverse_iterator`: const char s[] = "Hello, World!"; size_t n = strlen( s ); std::reverse_iterator< const char* > rev_it(s + n); | |
Re: What are the "crazy errors"? I suspect that it's an error in a templated function (they tend to give very verbose error messages). It's probably to do with this function: istream &operator>>(istream &input, Coordinate&) { input << endl; return input; } This will also give you an error: Coordinate Coordinate::operator!=const … | |
Re: You need to initialise all the values of the arrays `sum_darab` and `sum_hr`, not just the first element of each. I would do the initialisation inside the `for (j=0; j<sem; j++)` loop, not before as you have it currently. You will also have a divide-by-zero problem if you have a … | |
Re: I think that you need to use `memcpy` like this: memcpy( &DefaultComponentHolder, &tmp, DefaultComponents_Arraysize*sizeof( tmp ) ); `memcpy` needs to know the *total* amount of memory that it is going to copy. That is, the number of things multiplied by the size of each thing. The mysterious behaviour that you … | |
Re: > Why/how does 1011 represent the 5 1's at the start of the 32bit number? I'm trying to understand the concept and was trying to figure out how to do it by hand before attempting to write a text compression program. I've never heard of run-length encoding, but 101 is … | |
Re: I think (from your description) that you would just have to declare the `enemyMissileArray` variable in header for Cannon.cpp. However... (This next bit may or may not make sense to you, but it's the way I would do it. Ask if you don't understand) I would probably go for making … | |
Re: I hate it when you're waiting at a road crossing or an elevator and someone else arrives and pushes the button. What do they think you were doing? Just standing there trying to work it out? I always want to say "thank god you turned up! I could have been … | |
Re: Yeah, I'm not sure how many takers your going to get on this. In general, downloading and running random executables files from the internet isn't something people like to do. | |
Re: You can't really *remove* an element from an array, all you can do is over-write it. The trick is keeping track of which elements can be over-written and which you want to keep! The best way to do this would be to make a second structure, which "wraps" the array … | |
I was making an answer to a post and it ended up being much bigger in scope than the actual answer required. I thought it might make a good tutorial, but I don't see how I can post something in a "Tutorial" section directly? The only option is to "Post … | |
Re: You can think of two main kinds of relationships between classes in C++ * A class *is a kind of another class* * A class *has other classes inside it* The classic "*is a*" example uses animals. A dog *is* an animal. A cat also *is* an animal. So, for … |
The End.