2,898 Posted Topics
Re: > void h(void i() throw(int)); That is the declaration of a function called `h` which has no return value and takes one parameter, called `i`, which is a function with no return value and no parameters and that can only throw an `int`. When it comes to functions, you can … | |
Re: The best way to find out is to try them out. There are many non-trivial issues beyond what you can reasonably predict based on theories (time-complexity or whatever else). It also depends on the factors that rubberman mentioned. The fastest traversal is always going to be with compact and contiguous … | |
Re: You have an error with this line: relativeX = (relativeX*cos(angInRad)) - (relativeY*sin(angInRad)); relativeY = (relativeX*sin(angInRad)) + (relativeY*cos(angInRad)); because you set the `relativeX` value and then use it again in the next line. You need to preserve the original value of `relativeX` until you have computed `relativeY`. This is probably what … | |
Re: > I don't know what this means even after looking online, I'm going to guess the pointer isn't being deleted, so maybe somebody could help me. If a pointer wasn't deleted, the program would not crash, only leak memory (which the OS will reclaim anyways). I'm pretty sure that this … | |
Re: > is there any problem with initializing those pointers with the initialization list of the constructor? No. It's perfectly fine. But you need to know what to do with the pointers once your object contains them (is your object responsible for deleting it? (hint: it cannot).. can you guarantee that … | |
Re: If you compile with a very strictly standard compiler, then that line will indeed produce a compilation error. For instance, you can try it with the [online Comeau compiler](http://www.comeaucomputing.com/tryitout/) (pretty much the most standard-compliant compiler that exists). I'm not surprised that many compilers do not care about this exception-specification-related rule. … | |
Re: Here is an example of a recursive function (the `print_countdown` function, ignore the rest), you can copy-paste it and try it out: #include <iostream> #include <iomanip> #ifdef WIN32 #include <windows.h> static std::size_t get_stack_size() { MEMORY_BASIC_INFORMATION mbi; VirtualQuery(&mbi, &mbi, sizeof(mbi)); VirtualQuery(mbi.AllocationBase, &mbi, sizeof(mbi)); VirtualQuery((char*)mbi.BaseAddress + mbi.RegionSize, &mbi, sizeof(mbi)); VirtualQuery((char*)mbi.BaseAddress + mbi.RegionSize, … | |
Re: The `-o` is to specify the output of the compilation, so, when you right: $ g++ -o test.cpp RefEnv.cpp You are telling the compiler to compile RefEnv.cpp and produce an executable file called "test.cpp", and because RefEnv.cpp doesn't have the main function, you get the error that you get. So, … | |
Re: >Below is the one example that I can half way understand well enough to even start asking questions about linked lists. If that is the best example code you could find on linked-lists, then you're either very unlucky in your research, or half-blind. This code is crap. >Why is "struct" … | |
Re: In the newest standard, this function should be found under the `#include <numeric>` header. Also, I'm pretty sure that GCC has had this function and header for a long time (they list it as part of their 1998/2003 standard library, although it shouldn't be, to be strict) so it should … | |
Re: Calm down. There is always a good explanation for everything. Your problem is with the lines 41 and 42. You are returning a pointer to a local variable. That variable happens to be a pointer as well, but that doesn't change anything. Your function returns a pointer to a local … | |
Re: > Codemirror suppresses the browser's spellchecker highlighting Then, drop the codemirror, IMO. | |
Re: The code you posted is illegal, should not compile (if it does, go complain to your compiler-vendor). When you declare an array, with a line like this: int a[5]; Then, the number between the brackets is the total number of elements in the array (in the above, it's 5). When … | |
Re: I tried to post while logged out, it didn't work (using Chrome if that matters). I never seem to pass the "are you human" questions, which I think is wrong, unless I'm actually a robot. | |
Re: AD's right. The problem is probably with the return values of the set functions. I don't see anything else that could be wrong. Basically, if you don't return a value, then that creates an uninitialized value. This is simply because the memory for the return value is normally pre-allocated before … | |
Re: This happened to me a couple of times before, usually after switching to an experimental version of GCC from the svn development branch. Switching to a stable release or a newer version should fix the problem. This is definitely a problem with the compiler (GCC is usually pretty bug-free, but … | |
Re: Imagine I'm the user of your class. I'm not interested in knowing about T0 or T1. I don't care about how the class keeps the time periods. All I want is a clear way to use the class, e.g., start, stop, and get elapsed time. Thus far, your implementation seem … | |
Re: English please. $ sudo mount -t ntfs -o defaults /dev/sda5 /mnt/my_drive where `/dev/sda5` must be replaced by your hard-drives name, and `/mnt/my_drive` must be replace by whichever folder you which to mount the hard-drive into. | |
Re: "C# is like a newer version of C++" -- Microsoft's Ministry of Public Enlightenment and Propaganda Here goes another rant: C#, like most other programming language that came after C/C++, has a syntax that is largely based on or similar to C/C++. This is purely to ease the adoption of … | |
Re: Nobody wants to pay someone to learn, unless it's for a permanent position (learn for a while and then be a productive employee for several years). Your level of experience, as you described it, is minimal, you still have a long way to go kid. Your best bet is probably … | |
Re: If you hold an array of Y objects, then you can only store Y objects in it, nothing else. When you do `stuff[0] = Z();`, what you are really doing this is: create a temporary Z object, and then assign a Y object (the first in the stuff array) to … | |
Re: I think you are a bit confused about how instructions are executed on a virtual machine. The "stack" is not a stack of instructions, that's why you are confused on how to set it up. The instructions themselves are more appropriately stored in a queue or stored in a random-access … | |
Re: There have been some attempts at combining GIL and OpenCV, and two distinct projects on the GIL website are about the development of such an extension, see [here](http://opensource.adobe.com/wiki/display/gil/Contribute+to+GIL). I wouldn't exactly qualify OpenCV as a well designed library (much less than GIL), but it certainly is very feature-rich. The OpenCV … | |
Re: Look into [pipes](http://tldp.org/LDP/lpg/node12.html) in `*nix` systems. | |
Re: The Boost Graph libraries have an implementation of `A*` (and Dijkstra if you want) which both rely on a priority queue implementation that has more capabilities than the standard priority queue. Their priority queue implementation is also indirect which is also helpful. It supports functions like `push_or_update`, `update`, and `contains` … | |
Re: The most usual storage is in RGBA (usually the default in many places) and sometimes you see BGRA (used in TGA image formats, and some Mac or Adobe formats). As for big-endian versus little-endian, it doesn't really matter when you are getting the data from a file. In a file … | |
Re: It's not very clear what you are looking for, but here are a few suggestions that might be in the ball-park of what you are looking for: You can ask the compiler to produce an "assembly listing" (assembly listings are text-form assembly code, like the snippets that you posted) instead … | |
Re: The model-view matrix will always be applied to the vertices, so it makes no difference (speed-wise) whether the transformation is the identity matrix or whether it has any transformations accumulated in it (rotations and translations). OpenGL is given a model-view matrix and a set of vertices, and it will apply … | |
Re: Definitely, store them by value in the list, i.e. as `list<FileInfo>`. One advantage of linked-lists is that it almost never has to copy elements of the list (when inserting / deleting). So, you won't get any real penalty for storing a fairly large object by value in the list, if … | |
Re: Using a forward-declaration. A forward-declaration is a way to declare a class or function before its full declaration or definition can be written. There are restrictions on how you can use the class or function before its actual declaration or definition appears. In case of a forward-declared class, because the … | |
Re: You load the model, which usually includes values for the vertex coordinates, the normal vectors, the texture coordinates, and the color values, associate to each vertex. Then, you load the texture corresponding to the model, and you apply both. You never hard-code anything, you write code to load everything from … | |
Re: You open the terminal window and issue this command: $ sudo apt-get install flashrom upx That's all. | |
Re: This means you have to create a second array of the same size as the one to be sorted, and pass that second array as the "temp" parameter to the merge sort function. | |
Re: First of all, to add anything to the iso, you of course have to be able to open it and edit it. I assume you know how to do that. One other option is to create a bootable USB stick from the ISO, and then add your stuff to that … | |
Re: I think the guy in the tutorial made a mistake. What he is describing does not correspond to a rotation about the x axis. It seems to correspond to a rotation about the y axis (vertical). If you apply a rotation of -90 degrees about the y axis, you will … | |
Re: @AD: The docx format is not really a binary format, it is just a zipped xml file. You can decompress it with a standard zip library and then read / write it with any decent xml library, plenty of those are available in C/C++. | |
Re: Assembly, C and C++ are by far the most prevalent in that matter. I don't think there is any OS that is written with any other language. By far, it is dominated by C. Some lower-level details might be done in Assembly, and some higher-level parts might be done in … | |
Re: We're not going to do your homework for you. You need to show some efforts of your own towards solving this problem. Btw, the function you need for sorting an array is [`std::sort`](http://www.cplusplus.com/reference/algorithm/sort/). And your multiple sorting criteria is called a [lexicographic ordering](http://en.wikipedia.org/wiki/Lexicographical_order) (e.g. alphabetical ordering is a kind of … | |
Re: Ahh, good old bug-riddled GSL! If I had a dime for every bug in GSL, I'd be a rich man. Obviously, the problem is that you run out of memory. Meaning you have a memory leak in a loop. If you call the above function within a loop without freeing … | |
Re: Your random generation function is wrong. First, you should not seed the random number generator every time you query for a number. You should only seed it once at the start of the main() function. Also, your range computation in it is also wrong. You had this: ~~~ double ranDec(int … | |
Re: Rendering Bezier patches or NURBS surfaces isn't hard at all in OpenGL, not any harder than rendering a vertex buffer (the procedure is similar, you hand over the points to OpenGL and you call a render function on it). I suggest you [look into it](http://www.glprogramming.com/red/chapter12.html). | |
Re: I generally like the new editor and the markdown. It's not only simpler but also more feature-rich (at least it seems at first glance), which is a nice combination. But I have a few beefs: 1. The transition messed up some previous posts. For example, I wrote [two](http://www.daniweb.com/software-development/cpp/tutorials/378692/beginning-c0x-design-of-ownership) [tutorials](http://www.daniweb.com/software-development/cpp/tutorials/373787/beginning-c0x-making-a-raii-class) on … | |
Re: I think that line 130 should be: for (int j=n-1;j>=pass;j--) // notice 'n-1' instead of 'n-j'. | |
Re: A lot of things are wrong with your code. First of all, you have things that are just useless, like these types of things: if(min->NEXT != NULL) i->NEXT = min->NEXT; else i->NEXT = NULL; Tell me how that is different from this: i->NEXT = min->NEXT; ??? (rhetorical) Second, your code … | |
Re: First of all, there is no point in using the volatile keyword on a variable that is not shared between more than one thread. The whole idea of a volatile variable is to tell the compiler that this variable could change value at anytime, in parallel to the thread of … | |
Re: You should probably start by reading the instructions: "**use a class with 3 member functions** named InputMatrix, Calculate, and OutMatrix. ... **no global variables allowed**." You have some problems with your code, but they will be solved if you follow those highlighted instructions. [This tutorial](http://www.cplusplus.com/doc/tutorial/classes/) might help you. | |
Re: All your prof wants of you is that you compute the function given [here](http://en.wikipedia.org/wiki/Birthday_problem#Average_number_of_people) for M = 1000. It requires a loop and a few basic math operations. So much ink has been spilled on this issue, it's crazy. Forget all the random shuffling business. This is a just about … | |
Re: If you want to improve performance, you need to implement this as a [ring buffer](http://en.wikipedia.org/wiki/Circular_buffer). Also, your indentation scheme looks a little weird. And, obviously, you shouldn't use global variables. Learn to create classes and use objects. Finally, you include a header `std_lib_facilities.hpp`, I assume this header includes a number … | |
Re: I would try with negative Z values. Without rotations applied, the Z-axis points towards you (from the screen and out), with the zero being at the screen. This means that anything you draw in the positive-Z area is not going to appear on the screen (it is "behind" the camera). … | |
Re: You also should take a look at [Shader Designer](http://www.opengl.org/sdk/tools/ShaderDesigner/). This is an IDE for GLSL, I've used it in the past when I played around with shaders, it's pretty nice and easy. I think it also provides base codes to start from. |
The End.