2,898 Posted Topics

Member Avatar for oscargrower11

He's basically right. But I don't like his or your terminology. A pointer stores a memory address. When you use the new operator, you allocate a chunk of memory (either for a single object or for an array of objects) and it returns the address of the allocated memory, which …

Member Avatar for Lucaci Andrew
0
567
Member Avatar for poloblue

I think the only problem is a misplaced closing bracket. If you move the closing bracket at line 42 to line 56, then all should work. Right now, line 42 is where the while-loop ends, but it should end at line 56. Hint: Using proper indentation will help you identify …

Member Avatar for Lucaci Andrew
0
121
Member Avatar for triumphost

It's a simple typo. Line 14 should be: Test((void*)F); // notice no & here. Because when you do `&F`, the type of that expression will be `std::function<void()>**`, and then, later you cast that into the type `std::function<void()>*`, and thus, the crash (or undefined behavior).

Member Avatar for triumphost
0
1K
Member Avatar for triumphost

It is generally not recommended to do this at all. There is always the danger of the [static initialization order fiasco](http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14). I'm not sure how safe it is to do this for a standard component like `cout`. The safest thing is to just define a function that will perform this …

Member Avatar for mike_2000_17
0
131
Member Avatar for MooGeek

I'm an atheist, and have always been. My mother was born a catholic but was pushed away from it due to the horrible and discusting actions of the catholic church in the 50s, 60s and 70s, and once she left and stop being reinforced in the belief in God, the …

Member Avatar for Stuugie
0
356
Member Avatar for triumphost

> First, why does this not cause a stack overflow? If you call a function in an infinite loop, you will not get a stack overflow. The stack is, well, a stack. Things get pilled on and pulled off. You enter a function, it uses some space on the stack …

Member Avatar for mike_2000_17
0
108
Member Avatar for hanintalal

I just filled it. I hope you get a lot of people to fill it too, I will be interesting to see the results.

Member Avatar for hanintalal
1
142
Member Avatar for lewashby

For the samba problem, just run a search like this: $ aptitude search samba and it will print the list of packages with the name "samba" in it. You can just install all the packages that are relevant from that list. If a package appears in the list, then you …

Member Avatar for mike_2000_17
0
156
Member Avatar for Th3_M4TriX

The library should be part of "glibc" package, which is a fundamental system package, I doubt that you lack it. To find the `ld-linux.so.2` try to run this command: $ locate ld-linux It is possible that the file in question appears in the wrong directory, like `/lib64` or something. You …

Member Avatar for mike_2000_17
0
75
Member Avatar for alsz

This is a great start! You have clearly put some effort into it. The easiest way to solve this problem with the inputs of the rational numbers is to create a separate function for inputting and outputting a rational number. And the best way to do this is to overload …

Member Avatar for VernonDozier
0
385
Member Avatar for sternone

I find that Python is a really nice language to learn in addition to C++, because it is very different (very high-level), easy, and it works very well along-side C++ (Python is often used as a high-level scripting language to use to run C++ code, through python-bindings). > I read …

Member Avatar for sternone
0
248
Member Avatar for daino

I just wanted to point this out. Another solution is to simply attempt to compile everything with the C++ compiler. Technically, a C++ compiler cannot compile *any* C code, but it can compile *most* C code. Of course, if the C code is a large code-base and all, you shouldn't …

Member Avatar for rubberman
0
262
Member Avatar for triumphost

Well, I happen to have written a tutorial on how to write a class like that. Read it [here](http://www.daniweb.com/software-development/cpp/tutorials/373787/beginning-c0x-making-a-raii-class). Your class is no different than the standard [`std::vector`](http://www.cplusplus.com/reference/stl/vector/) class (except that the standard class has way more features). So, I recommend you use that instead.

Member Avatar for rubberman
0
140
Member Avatar for VernonDozier

You can assume, for all practical matter, that the `std::vector` class just stores two fields: the size of the array and a pointer to the first element of the array. In other words, this is the same as what you would have to do if you allocated the dynamic array …

Member Avatar for VernonDozier
0
384
Member Avatar for dk4411

I ran your code and I get exactly what is expected. That is, I called `$ ./clone_test 2` and I got this output: PID = 27719 PPID = 27718 PID(child of a child) = 27720 PPID(child of a child) = 27719 PID = 27721 PPID = 27718 PID(child of a …

Member Avatar for dk4411
0
200
Member Avatar for triumphost

Did it occur to you that you can test this out very easily? When it comes to performance, the only thing that can settle the argument is test results, the rest is just speculative non-sense. Try this: #include <iostream> #include <ctime> #include <algorithm> #include <cstring> #include <iomanip> union Record { …

Member Avatar for mike_2000_17
0
272
Member Avatar for triumphost

The general rule is this: 1. Prefer declaring / defining your operator overloads as non-member functions; 1. If you need access to private members, make them non-member friend functions; 1. If that particular type of operator must be a member function (like the assignment operator, or conversion operators), then make …

Member Avatar for triumphost
0
2K
Member Avatar for mike_2000_17

I am currently working on kind of multi-graph structure. The thing is that two graphs are needed for my application which span the same vertices but with two distinct set of edges (i.e., a multi-graph). The first graph is a binary search tree, while the second graph must be general …

Member Avatar for mike_2000_17
0
681
Member Avatar for triumphost

You've been busy! Pretty nice code you have there. There is one important mistake for sure, you allocate your pixel array as `Pixels = new RGB[size];` where size is the size in **bytes** of the image. So, you need to allocate the pixels as `Pixels = new RGB[width * height];`. …

Member Avatar for triumphost
1
446
Member Avatar for lewashby

You can also try to download the package separately and manually swap it. You can download the package from [here](http://pkgs.org/ubuntu-12.04/ubuntu-main-amd64/e2fsprogs_1.42-1ubuntu2_amd64.deb.html). If the problem persists after you have checked the MD5 checksum, then you should report it to ubuntu bug-tracking.

Member Avatar for mike_2000_17
0
185
Member Avatar for tomtetlaw

Well, DeanMSands3 was right about one thing: the original loop was erroneous. The correct solution is this: indices = malloc (sizeof(short) * data.face_count * 3); for (i = 0; i < data.face_count; i++); // notice i++ and not i += 3 { indices[3 * i] = data.face_list[i]->vertex_index[0]; indices[3 * i …

Member Avatar for DeanMSands3
0
150
Member Avatar for tensity

And, if you want the numbers to be aligned to the right, you have to put the setw immediately before you print the number and you can also use setprecision to have only two numbers after the dot (for floating-point numbers), as in: cout << setprecision(2); cout << setw(23) << …

Member Avatar for tensity
0
125
Member Avatar for coffecat

Here are some initial comments: **Style** Overall the coding style is OK, but a bit unusual. Naming functions like `Pull_randWord` is a bit unusual, but more importantly, it is not consistent with the rest of the code, you should pick one style and make it consistent. Then, using all upper-case …

Member Avatar for Schol-R-LEA
0
326
Member Avatar for lewashby

Well, first of all, there's a typo in what you have posted. In the source path, `developer@192.168.1.9:/home/develope/fromlaptopsaveDeveloper.tar.gz`, you are missing the R in `developer` folder name. It could very well be just that. Otherwise, your destination is weird. You send the file to the desktop under username garrett, but the …

Member Avatar for mike_2000_17
0
279
Member Avatar for phfilly

Your operator overload is for `Element + Element` not for `int + Element` or `Element + int`. You can fix the problem by defining those operator overloads, as free-functions: Element operator+(const Element& lhs, int rhs); Element operator+(int lhs, const Element& rhs); and implementing them as you see fit. BTW, it …

Member Avatar for rubberman
0
168
Member Avatar for s0urce

There are a few issues with your code. First, your ImplementCalculations function doesn't need to take those three parameters because they are already part of the class (and object). Also, you should probably name the function a bit better, like "ComputeOvertime" or something like that. Second, you probably shouldn't call …

Member Avatar for s0urce
0
141
Member Avatar for phorce

Git is built like most other Unix/Linux tools, as a set of command-line tools (programs) with options. The best library for the purpose of creating an option-rich command-line program is the [Boost.Program-Options](http://www.boost.org/doc/libs/1_49_0/doc/html/program_options.html). If what you want to do is create a shell program (like bash), then it's a whole other …

Member Avatar for Schol-R-LEA
0
136
Member Avatar for ChrisMackle

Why does the compilation of "main.cpp" trigger error reports coming from "player.cpp"? You are not `#include`ing "player.cpp" from your "main.cpp" file, are you? This has to be coming from an undeclared type or variable. The real error is at "player.cpp" at line 43, the rest is just noise from the …

Member Avatar for mike_2000_17
0
272
Member Avatar for jkon

If I was able to travel back in time, I would probably also be able to travel very large distances instantly. I think I would travel back to a long time ago in a galaxy far, far away....

Member Avatar for Dani
0
280
Member Avatar for johnsmith111

> I am more interested in knowing if a certain distribution of Linux is better supported for Hadoop and why? Don't know about Hadoop specifically, but I would imagine that Red Hat Enterprise Linux (Server) is one of the best OS for this application (and by "best OS", I don't …

Member Avatar for mike_2000_17
0
157
Member Avatar for DemiSheep

Well, maybe you should start by trying to locate the declarations of `HT` and `pos`, because, as the compiler says, they are not declared in that scope. For your function prototype to be valid, `HT` should be a type and `pos` should be a `#define`. I see no such thing …

Member Avatar for Despairy
0
176
Member Avatar for cool_zephyr

Well, obviously, you can't hard-code the vertices into your program (your post almost made it sound like that is what you are trying to do). You must store the mesh (list of vertices and polygons) into a file that you can load and display. Or, you should generate simple geometric …

Member Avatar for cool_zephyr
0
181
Member Avatar for fka

I believe you need a parent QWidget for your new window. And, I also think that your window should be persistent, if you are going to just `show()` it (as opposed to `exec()` it). So, I think that the following should work better: class MainWindow : public QMainWindow { Q_OBJECT …

Member Avatar for mike_2000_17
0
198
Member Avatar for Sasstraliss

The guidelines for the two algorithms are basically the same as for their respective mother-algorithms, i.e., the sorting algorithms. The counting-selection algorithm is only applicable to a very tightly packed integer-valued array. What I mean by that is that the bound (`cap` in your function) has to be very small, …

Member Avatar for mike_2000_17
0
532
Member Avatar for Chuckleluck

You need to `delete` every thing that has been allocated with `new`. It's as simple as that. In practice, however, it can be complicate to ensure that nothing is left behind (undeleted). There are many techniques and guidelines to follow in order to help you with that. I wrote two …

Member Avatar for Chuckleluck
0
217
Member Avatar for SCass2010

The compilation success is contigent on the fact that the compiler allows `0` to be implicitly converted to the pointer type `DOMNode*`. I'm not sure what is the standard behavior required here. In general, if you replace `0` with `NULL`, it should work, because `NULL` must be convertible to any …

Member Avatar for deceptikon
0
163
Member Avatar for daino

> Would anyone know what is meant by dynamically linking to qt libraries?? Well, this is just a matter of knowing what dynamic linking means. Take [wiki](http://en.wikipedia.org/wiki/Dynamic-link_library) for a start. As a quick explanation, let me start from the basics. You have some code. In a usual project, you'll have …

Member Avatar for daino
0
117
Member Avatar for jaskij

> starting names of all classes and variables of composit data types with capital and of base types with a small letter. That is very odd indeed. The most important thing about coding conventions, is that they should be conventional. It's like with a standard, it doesn't matter as much …

Member Avatar for two[ ][ ]
0
176
Member Avatar for MrEARTHSHAcKER

It's a trade-off between speed and safety. Generally, in many places, C++ standard libraries and their implementations put the emphasis on speed. This is why many STL container functions do not have bounds checking (or they have it only as an `assert` condition), although there are bound-checked alternatives like the …

Member Avatar for MrEARTHSHAcKER
0
2K
Member Avatar for happygeek

Congrats on your fourth grand-kid! I'm really sorry to hear about your eye affliction.. I wish you the best of luck and success in treatments. Being the robotic geek that I am, I have to mention this. Coincidently, a couple of weeks ago, I just attended [this plenary talk](http://www.icra2012.org/program/schedule.php) (which …

Member Avatar for mike_2000_17
3
233
Member Avatar for sara5454

That program is equivalent to this: if(A + B < 20) A = A + 5; else A = A - 1; Line-by-line, you have: LOAD A ADD B Puts the variable A on the register, and then adds the value of B to that. So, it computes `A + …

Member Avatar for sara5454
0
162
Member Avatar for sara5454

The errors are due to the fact that this assembly code is not real assembly code. This is just a simplified syntax to teach the logic of it. The actual syntax is quite a bit more complicated. Here is the AT&T syntax that is equivalent to your program ("AT&T" syntax …

Member Avatar for mike_2000_17
0
548
Member Avatar for thedarklord

Calculating the complexity of an algorithm is really just a matter of figuring out how many times an operation will be done. If you take the outer loop, `for(int i = 1; i <= n; i *= 2)`, you can ask yourself how many iterations will be executed. If n …

Member Avatar for mike_2000_17
0
181
Member Avatar for Humayoon Khan

> please note that i am reading a file that consits of all characters (ascii 0-255) therefore i must use wstring instead of string.. I doubt that this is true. A normal character (`char`) is one byte in size, and it can represent 256 characters (many of which don't actually …

Member Avatar for Humayoon Khan
0
3K
Member Avatar for Humayoon Khan

You must transfer the data into an array (or vector) that you can use to manipulate the data. Then, you save the data back to the file, overwriting it. The rdbuf is really not meant for you to tamper with, and you certainly cannot use it to modify the content …

Member Avatar for Humayoon Khan
0
124
Member Avatar for lewashby

> The function rand_0toN1 returns rand() % n, in this case I believe that it's returning a random number from 1-10 because 10 was passed as an argument through n, which is not the same n that was declared at the beggining of the program but local to the function …

Member Avatar for WaltP
0
77
Member Avatar for Sendy Hipo

> but there's no further explanation why i must convert the it to cstring, anyone knows? Yeah, I know. The reason is because of the original design of the libraries, in particular the iostream and the string library. Basically, they were developed more or less in isolation, and iostream came …

Member Avatar for Sendy Hipo
0
154
Member Avatar for Avenger_123

This is not a program, it is a function. What it does is to compute the inverse of a matrix through a [Gaussian elimination](http://en.wikipedia.org/wiki/Gaussian_elimination). The implementation itself is very naive, meaning that it is inefficient, numerically unstable, and also programmed in bad style, not to mention that this is basically …

Member Avatar for mike_2000_17
0
323
Member Avatar for SixtyFourBitFox

The library to do this is called winsock. This is a standard Windows library and it is usually installed with any compiler you have and is also pretty simple to use. You can following [this msdn guide](http://msdn.microsoft.com/en-us/library/windows/desktop/ms738545(v=vs.85).aspx) to get acquainted with the library. If you have any more specific questions …

Member Avatar for SixtyFourBitFox
0
252
Member Avatar for VernonDozier

You have a massive memory-leaking loop. No surprise that it crashes your system. In the loop inside main, you allocate B objects and never delete them. This is a more correct loop: for(int i = 0; i < 1000000; i++) { A* obj = new B(); obj->foo(); delete obj; // …

Member Avatar for mitrmkar
0
271

The End.