2,898 Posted Topics

Member Avatar for Gaiety

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 …

Member Avatar for mike_2000_17
0
128
Member Avatar for DavidB

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: …

Member Avatar for DavidB
0
4K
Member Avatar for NunsBeachSurfer

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 …

Member Avatar for mike_2000_17
0
301
Member Avatar for kendaop

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 …

Member Avatar for kendaop
0
653
Member Avatar for Jsplinter

> 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) …

Member Avatar for Jsplinter
0
4K
Member Avatar for dimitrije17

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.

Member Avatar for dimitrije17
0
253
Member Avatar for Lord_Migit

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 …

Member Avatar for Lord_Migit
0
258
Member Avatar for NetJunkie

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 …

Member Avatar for Reverend Jim
0
967
Member Avatar for abdelhakeem

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 …

Member Avatar for abdelhakeem
0
220
Member Avatar for DubyStev

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 …

Member Avatar for mike_2000_17
0
241
Member Avatar for sciwizeh

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 …

Member Avatar for sciwizeh
0
253
Member Avatar for poolet

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 …

Member Avatar for mike_2000_17
0
173
Member Avatar for hamzakhan

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 …

Member Avatar for mike_2000_17
0
195
Member Avatar for BigEEter

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 …

Member Avatar for BigEEter
0
394
Member Avatar for asif49

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 …

Member Avatar for asif49
0
680
Member Avatar for MasterHacker110

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 …

Member Avatar for MasterHacker110
0
193
Member Avatar for VengefulToast

> 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 …

Member Avatar for Rashakil Fol
0
267
Member Avatar for Andy90

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, …

Member Avatar for mike_2000_17
0
148
Member Avatar for Labdabeta

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 …

Member Avatar for hekri
0
147
Member Avatar for triumphost

> 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 …

Member Avatar for mike_2000_17
0
2K
Member Avatar for cent91

>> 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 …

Member Avatar for thines01
0
631
Member Avatar for triumphost

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 …

Member Avatar for mike_2000_17
0
456
Member Avatar for eagle_phoenix2

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 …

Member Avatar for eagle_phoenix2
0
702
Member Avatar for khuzdaar

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 …

Member Avatar for khuzdaar
0
517
Member Avatar for anonymous1987

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 …

Member Avatar for ravenous
0
342
Member Avatar for triumphost

> 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 …

Member Avatar for mike_2000_17
0
1K
Member Avatar for lewashby

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 …

Member Avatar for lewashby
0
153
Member Avatar for BryantFury

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 …

Member Avatar for BryantFury
0
251
Member Avatar for binningen

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 …

Member Avatar for mike_2000_17
0
167
Member Avatar for mayapower

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 …

Member Avatar for mike_2000_17
0
255
Member Avatar for nitinmbhanu

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 …

Member Avatar for mike_2000_17
0
1K
Member Avatar for greencode

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 …

Member Avatar for WaltP
0
325
Member Avatar for Ancient Dragon

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 …

Member Avatar for Ene Uran
1
189
Member Avatar for Grenwood

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 …

Member Avatar for Grenwood
0
228
Member Avatar for triumphost

> 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();`. …

Member Avatar for triumphost
0
186
Member Avatar for Chuckleluck

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: …

Member Avatar for mike_2000_17
0
181
Member Avatar for triumphost

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.

Member Avatar for L7Sqr
0
141
Member Avatar for dinosaur123

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, …

Member Avatar for dinosaur123
0
271
Member Avatar for tendaishava

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 …

Member Avatar for mike_2000_17
0
285
Member Avatar for suhasgh

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 …

Member Avatar for suhasgh
0
113
Member Avatar for Labdabeta

> 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, …

Member Avatar for Labdabeta
0
224
Member Avatar for mrnutty

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 …

Member Avatar for nezachem
1
675
Member Avatar for SCass2010

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, …

Member Avatar for mike_2000_17
0
2K
Member Avatar for sharath_137

> 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 …

Member Avatar for Banfa
0
594
Member Avatar for Lucaci Andrew

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).

Member Avatar for Lucaci Andrew
0
172
Member Avatar for caltech

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.

Member Avatar for mike_2000_17
0
362
Member Avatar for vedro-compota

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 …

Member Avatar for WaltP
0
169
Member Avatar for bobanderson90

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 …

Member Avatar for mike_2000_17
0
1K
Member Avatar for MasterHacker110

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 …

Member Avatar for mike_2000_17
0
232
Member Avatar for nuclear

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, …

Member Avatar for mike_2000_17
0
246

The End.