2,898 Posted Topics
Re: Basically, the difference between a mutex and a *binary* semaphore is that the semaphore is a more general mechanism which makes it somewhat less appropriate to do the same job as a mutex (although I guess it might be faster on some implementations). Because you can have semaphores that carry … | |
Re: The line that is outputted by "last reboot" is not the time of the last reboot but the time since when the reboots have been recorded: wtmp begins Wed May 9 15:23:19 2012 For example, if I run the command on my laptop that I'm using now, I get this: … | |
Re: That's a good point deceptikon, do you have a solution? I do, of course, but it gets tricky. Of course, you can't use `memcpy` and expect well-defined behaviour for any non-POD type. You can manage to force an element-wise copy-construction into the destination array by the following trick: template <typename … | |
Re: So, if I get this right, you want to train an ANN to be able to determine if there is a path between the current player position and the target. Frankly, this is not going to work. You would need a very deep ANN to get this working (deep means … | |
Re: > A) Does it already exists? No. Unless you are working on a very unusual platform that has a native word size of 3 bytes (most systems have a native word size of 4 or 8 bytes, and some really small embedded systems might use 2 bytes natively). > B) … | |
Re: Definitely, put the task on the scheduler. Would you really expect the computer it is running on to run continuously for 2 months? Especially on a Windows system. | |
Re: The correct ending for your main function is this: delete iVector1[0]; iVector1.at(0) = new Test(21); delete pVec1->at(1); pVec1->at(1) = new Test(22); for(int i = 0; i < iVector1.size(); ++i) delete iVector1[i]; for(int i = 0; i < iVector2.size(); ++i) delete iVector2[i]; }; As for the linking error, this is not … | |
Re: Shortly after getting my hands on my first computer when I was 13 (in 1998 or so) I wondered how applications were made, so I started making simple GUI apps with RapidQ (a free open-source VB-like programming language and GUI tool). A couple of months later I switched to Delphi … | |
Re: I hope you liked my tutorial, except for that one confusing part! > Isn't the compiler-generated copy constructor called if I used an rvalue like int_vector(int_vector(5)) No. The compiler-generate **move** constructor will be called if you used an rvalue like `int_vector(int_vector(5))`. In C++03, it would be the copy-constructor (and that … | |
Re: If you allocated the arrays dynamically, then you don't have an array object to pass to the function, you only have a pointer to the first element of an array. In other words, the only option you have is to pass by pointer. If you store your 2x2 or 3x3 … | |
Re: This problem is related to a classic issue in software engineering, called "Double Dispatching". Many of the most prominent people in the computer science field have discussed this problem, and it seems there is really no generally scalable (non-exponential) solution to this problem, other than converting everything to some common … | |
Re: If you want an answer, you must reduce the problem down to the more essential parts of the code, and provide more details as to what the problem actually is. You can't expect people to go through all this code and figure out by themselves what the problem is, and … | |
Re: C++ by itself is not built-in with such graphical tools. You need to use a library and toolkit for Graphical User Interface (GUI) programming. Depending on the environment you are working in (windows, linux, mac), there are different options. And, in general, it is difficult to use these libraries without … | |
Re: I think that your design is somewhat flawed. First of all, you require the catcher to know and require that the exception is one that is being logged, which you may not always want to do and may not be able to do in certain cases, leaving your catch-clauses very … | |
Re: Here is the thing with the "drawing a line". Draw a simple cartesian plot. Consider that 1 = true and -1 = false. Put a dot in the graph for each possibility (1,1), (1,-1), (-1,-1), (-1,1). According to XOR logic, only the points (-1,1) and (1,-1) yield "true" after a … | |
Re: The problems you are reporting is not a matter of compiler issues, it is simply the fact that you don't understand that code that is built and made to link to MSVC compilers cannot link with code that you compile with GCC (used by CodeBlocks, through the MinGW port of … | |
Re: > game and simulation degree from DeVry University Sounds like a scam to me (in fact, DeVry, in particular, have been in and out of courtrooms for years for scam-like behavior). Stay away from these for-profit colleges. When they boast numbers like 90% employment in "related" fields after graduation, it … | |
Re: You don't need to "obtain" a software license from anywhere. When you are the author of a piece of software, you automatically have the copyrights to it (copyrights just mean that you get to decide who can use it, to what extent, for what purpose, and for what price). Now, … | |
Re: QWERTY here too. I'm afraid your friends might be right, you are abnormal. Personally, and especially for programming, I find that the placement of the non-letters in a QWERTY layout has more of an impact (and that is not significantly different in dvorak). With code-completion, you don't end up writing … | |
Re: > Not only that but I'd have to constantly switch back and forth between headers and sources to see whats declared where or what contains what. If it annoys you to switch back and forth between the header and source when you are implementing the functions, then here's a trick … | |
Re: >> i would love to do system programming or game programming. System programming: Learn C and get some basics in assembly. Game programming: Learn C++. The computer game industry is entirely dominated by C++ (and it is probably good to know C and assembly as well). >> i dont like … | |
Re: You don't need to use variadic templates for this. And you certainly don't want to go with the var-args solution that was suggested. There is something called `std::bind` and `std::function`. The first allows you to bind any number of arguments to a function pointer and basically transform that function pointer … | |
Re: Visual studio comes with a command prompt application to replace the cmd.exe from Windows. That visual studio command prompt is basically the same as the cmd.exe except that it initializes all the necessary environment variables when it is started. I see no reason not to use it since it doesn't … | |
Re: Blackjack is definitely more manageable. All you need is a random-number generator (the `rand()` function) to draw the cards (or a bit more than that if you want to draw cards from a actual deck with a finite number of cards, as opposed to an "infinite" deck of cards) and … | |
Re: Well, this line doesn't make any sense: list == argv[3]; Neither does this one: cout << *list << endl; Maybe you should explain what you think these lines are supposed to do, because it doesn't seem obvious to me (nor for the compiler). The variable `list` is a vector of … | |
Re: > How does Notepad++ do it Notepad++ uses Scintilla as a back-end for the [syntax highlighting](http://en.wikipedia.org/wiki/Syntax_highlighting) and other coding-related features (code completion, etc.). Most IDEs and enhanced text editors (like Notepad++, emacs, vim, etc.) use only a limited number of libraries that do the actual syntax highlighting. There is no … | |
Re: Netbeans requires that you install the compiler separately (because it can work with different compilers). MS Visual C++ installs the MS compiler along with the IDE, that's why you won't have that problem with MSVC. If you also have MSVC installed, then you should be able to configure Netbeans to … | |
Re: For the delete function, you have to do more or less the following: - Ask the user for the product name to delete. - Check if the `startPtr` has that product name - if it does, then `delete` the `startPtr` and set it to the next node, i.e., `startPtr->nodePtr`, and … | |
Re: The pointer `oldArr` within your function is not the same pointer as the one you pass to it (caller-side). The value (address it stores) is the same (copied when entering the function) but the pointer itself is not the same variable. What you need to do is pass it by … | |
Re: You could use inheritance (OOP) but it would be very wasteful for such small attributes. Basically, what you need is a class template like [Boost.Variant](http://www.boost.org/doc/libs/1_49_0/doc/html/variant.html) as your "NAttrib" implementation, while your FloatAttribute and ComplexAttribute can remain very simple (no template, no inheritance). This is fairly advanced and uses templates and … | |
Re: This is annoying me, so let me rant a bit on this. First of all, I think your caps-lock key is defective or something. Writing everything in upper-case letters just makes you look stupid, I'm sure that's not your intent, so you might want to get that fixed. Second, this … | |
Re: You need to first read the entire line as a single string, and then read off the individual numbers in it. Because, when you read numbers from the file, it will ignore any non-number character (including the new-line character) that it encounters. So, there is no way to tell when … | |
Re: You think robo calls are bad. Here in Canada, there were robo calls by the conservatives directed at the people favorable to an opposing party, the calls redirected them to the wrong location to go and vote. It's been a big scandal for the past few weeks. I guess the … | |
Re: This is what is called a signals and systems implementation (at least, that's how I call it..). I had a similar problem a while back, when writing a piece of control software for a humanoid robot. This is actually not trivial to do correctly, as I'm sure you have figured … | |
Re: > Does ^ Replace the & operator? No. The `^` is equivalent to `*`, while the `%` is equivalent to the `&`. Except that the `^` and `%` are for garbage-collected (or .NET) objects only. In other words, you allocate a GCed object with `MyClass ^ obj = gcnew MyClass();`. … | |
Re: The dot operator and member function call have priority over the dereference operator. This means that the expression `*ptr.str.at(1)` is evaluated as `*(ptr.str.at(1))`, and that is why you get the error "str" is not a member of the pointer type `grid*`. To fix it, you just need parentheses, like so: … | |
Re: Are you aware that union types can have constructors, destructors, and member functions (but not virtual ones). Maybe that can help you solve your problem, which I don't quite understand. | |
Re: Sorting with respect to two things (SalesGrp and PartNum) in a way that if the first elements are the same, then sort with respect to the second element, that is called lexicographical sorting (and alphabetical sorting is a kind of lexicographical sorting, where each element is a character). In short, … | |
Re: First of all, the field in question is [computational geometry](http://en.wikipedia.org/wiki/Computational_geometry). Then, within that field there are volumetric representations and boundary representations (or B-Rep). Most B-Reps are parametric. There are a number of fundamental representations used for curves and surfaces (and higher order geometries). Most are based on the construction of … | |
Re: Yes, in a few different ways. First, if C derives from B, then it is also derived from A, through the fact that B is derived from A. In other words, derived classes inherit from their base class(es) and all their base class(es). Second, C++ also permits multiple inheritance, meaning … | |
Re: > So then, how do games like Call of Duty do it? Clearly they are able to set up a server (host) and clients. Ever heard of [Service Discovery Protocols](http://en.wikipedia.org/wiki/Service_discovery) (SDP), and other systems like [Zeroconf](http://en.wikipedia.org/wiki/Zero_configuration_networking) and [UPnP](http://en.wikipedia.org/wiki/Universal_Plug_and_Play). When nezachem suggested that you put the discovery part aside for now, … | |
Re: The logic is that the preferred position is the highest power of 2 that fits entirely inside N. The process is like this, at every round, the first element will be taken out and the second element will be left along with every two element following it. After the last … | |
Re: As deceptikon says, it can be done, and probably more easily through function overloading (a free function taking the ObjectHolder and the ClassName and type), because then you can overload based on the class type and change the return type accordingly, which is harder to do as member functions. However, … | |
Re: > Wanna bet??? ;-) I was just listening to Herb Sutter's C++11 presentation for GoingNative 2012 where he argues that there isn't really much reason for the `new` operator to even appear in modern C++ code (and certainly not `delete`, which I haven't used in ages), let alone `malloc/calloc/realloc`. Considering … | |
Re: This is not gonna be a problem. When you call a member function of a class, it is called on the object pointed to by the "this" pointer. So, the this->id is the vector within that object, so it will be modified directly (without a copy). | |
Re: To add to Tumlee's comments, I would suggest your prototype for the printPayroll function should be like this: void printPayroll ( const vector<Records>& v ); Use the passing by const-reference to avoid copying such a large object as a vector. | |
Re: In reality, you could probably use some clever bit-wise tricks and some low-level instructions to quickly extract this kind of information (which is probably what library code does). But that's too complicated to do in an exercise question. Assuming you will not go as far as outputting the result in … | |
Re: Correction on Banfa's last post. You cannot make the assignment operator into a free function, it must be a class member function. So, Banfa's code will not work, although he is very correct in suggesting the free function operator overloading instead of as class member functions, this is generally preferrable … | |
Re: The easiest would probably be to reinstall backtrack linux, and merge the partitions as part of the install process. You can always backup the home folder (or others) and any other system files (which you can later resynchronize with `rsync`, or manually with `diff` on all the config files). And … | |
Re: An API (Application Programming Interface) refers to a set of specifications on how you can make function calls to a library to perform certain operations (basically, a specification, from a programmer's point-of-view, on how to use a library). An SDK (Software Development Kit) is a set of tools and documentation, … |
The End.