2,898 Posted Topics

Member Avatar for lochnessmonster

Usually if it makes sense to you, it will make sense to others, given the proper documentation. Whether your code is to be published or not does not make a difference because you should always write your code as if it was to be published. Put care into thinking about …

Member Avatar for mike_2000_17
0
192
Member Avatar for dophine

>>I expect the copy constructor should be called after the temp object is created. >>But why no "copy" is displayed? Because the second line "D d1 = D(23);" is an explicit conversion. One way to look at it is in terms of optimization, that is, this is a trivial case …

Member Avatar for mike_2000_17
0
108
Member Avatar for geethasree

I think that [URL="http://www.boost.org/doc/libs/1_44_0/doc/html/thread.html"]Boost.Thread[/URL] is by far the easiest solution (I'm not sure how well it is usable on Solaris, but I presume it is alright.. at leas the latest version). Here is how I would do it: [CODE] #include <boost/thread.hpp> class MyClass { //blablabla //need to provide a copy-constructor …

Member Avatar for geethasree
0
2K
Member Avatar for samsons17

There are just a few mistakes (proper indentation helps to see these mistakes): [CODE] char large(char *p,int a) { int large=0,x=0,b; //x should start at zero. char r; for (int i=0;i<a;i++) { for(int j=0;j<a;j++) { if(*(p+j)==*(p+i)) //notice the difference here *(p+i) instead of *p+i, and the i != j is …

Member Avatar for samsons17
0
409
Member Avatar for Nathaniel10

I would recommend that you simply comment out all the code in main() and put the lines back in one at a time and check the output. This is a good exercise to understand how objects are created and assigned to values, but it is for you to work out …

Member Avatar for Nathaniel10
0
87
Member Avatar for smoothe19

First, I recommend you use a boost::shared_ptr for all "next" pointers and a boost::weak_ptr for all "prev" pointers, this will allow you to get rid of your destructor altogether. Second, you should think whether you really need a copy-constructor for your queue. If you don't need it, make the class …

Member Avatar for akgh2010
0
180
Member Avatar for rebellion346

I think you should make all those data members under the "protected" scope instead of "private", that would solve all your problems.

Member Avatar for rebellion346
0
92
Member Avatar for someguyjbb

Between line 17 and 18, add the following: [CODE] first = NULL; last = NULL; [/CODE]

Member Avatar for Ancient Dragon
0
118
Member Avatar for someguyjbb

You must show the declaration of CharQueue in order to find the mistake. For ArrayCharQueue class to be abstract, it means that the CharQueue is abstract (has a pure method ("= 0;") that is not implemented in the ArrayCharQueue class).

Member Avatar for mike_2000_17
0
114
Member Avatar for ixmike88

It might be possible that the DLL function throws an exception, and exceptions cannot cross module boundaries (you cannot throw an exception in a DLL and catch it in the exe). That could be the source of the problem. Maybe you can try to wrap the entire function ProcessCommand with …

Member Avatar for mike_2000_17
0
706
Member Avatar for merse

If you want a fixed number of iterations, use an integer value to control the iteration number and progress. [CODE] for (int i = 0; i < MaxIter; ++i) { double x = dx * i; // numeric code } [/CODE] Many numerical methods do not require a fixed amount …

Member Avatar for merse
0
372
Member Avatar for mushahidh

For basic 2D drawings, there are a few options that I can think of. First, if you don't need to have much of a Graphical User Interface, Simple DirectMedia Layer ([URL="http://www.libsdl.org/"]SDL[/URL]) is quite easy to use and allows you to draw simple shapes (circles, lines, rectangles, text, etc.). Second, if …

Member Avatar for jonsca
0
3K
Member Avatar for daviddoria

Since the compiler uses the type of the parameter to figure out which template to instantiate, the only information it has is the type of the parameter, it cannot "back-trace" the type from which this parameter type comes from. This is because it cannot assume that the only type T …

Member Avatar for daviddoria
0
3K
Member Avatar for arithehun

Being a robotics engineer, I feel a bit obligated to answer... but also very happy to do so, however, your question is too vague, thus, my answer will be as well. >>learn the SDK in C++ What SDK? What is the platform? Is it the LEGO Mindstorm? Or a micro-processor, …

Member Avatar for arithehun
0
1K
Member Avatar for andre13

As ixmike pointed out, c is useless, and most importantly, i is not initialized (and should probably be an integer, int, and not a double). Now, the input of p and the condition for the loop are not correct. The thing that you have to notice in this problem is …

Member Avatar for mike_2000_17
0
132
Member Avatar for tagazin

Try to reinstall the build-essential package (uninstall and reinstall). That's the only suggestion I can think of... hope it helps.

Member Avatar for tagazin
0
129
Member Avatar for ixmike88

I think that your cast to LPCWSTR is not correct. Read [URL="http://www.codeproject.com/KB/string/cppstringguide1.aspx"]this article[/URL] for a deeper explanation.

Member Avatar for ixmike88
0
3K
Member Avatar for namasee

>>I m a computer engg student & m absolutly unable 2 undrstand c++. Cn any1 sggst sme buks or ways 2 stdy C++??????? I have a book to suggest: an English dictionary! Communication is one of the most important skills in engineering.

Member Avatar for mitrmkar
0
97
Member Avatar for ixmike88

Making a Plugin System is not a trivial task... One of my friends who is very experienced tried and gave up. I made one (for windows) four years ago, and it took me about 1.5 years to get it to work properly. Now, I started a new one about 1 …

Member Avatar for ixmike88
0
127
Member Avatar for EngSara

Well, I don't agree with AD about how writing beyond an array will corrupt the heap, it might throw an Access Violation or segmentation fault, but not corrupt the heap (it would be wonderful if it did, it would make heap-related bugs so much easier to find! I know by …

Member Avatar for shijobaby
0
183
Member Avatar for vbx_wx

This implementation is called the "dreaded diamond", this [URL="http://www.parashift.com/c++-faq/multiple-inheritance.html#faq-25.8"]faq[/URL] is very explanatory. @arshad:>>My respect for Visual studio has increased after reading your comment @Fbody:>>Users of VC++ are the lucky ones MY respect for Visual studio has _decreased_ (even more) since I saw your post. I tried to find a part …

Member Avatar for mike_2000_17
0
105
Member Avatar for mike42intn

Your problem is that the constructors for TwoDimensionalShape and ThreeDimensionalShape do not carry the parameters over to the base class Shape: [CODE] //This is what you had: TwoDimensionalShape(double x,double y) { double Shape(double x,double y); } //This is what it should be: TwoDimensionalShape(double x,double y) : Shape(x,y) { }; //and …

Member Avatar for mike42intn
0
474
Member Avatar for nayefc

As pointed out by Fbody, your copy-constructor has not a single statement that sets the mHead and mTail pointer to anything. The fact that the copied list outputs the list without the head node, is pure luck, it should just output random shit or simply crash on a segmentation fault. …

Member Avatar for nayefc
0
3K
Member Avatar for meazza

The main problem is that you need to get rid of header stdlib.h it corrupts the call to getline. One simple error is that your file in the search function should be of type "ifstream" not "ofstream", calling a getline on an ofstream will likely lead to an abnormal termination …

Member Avatar for meazza
0
292
Member Avatar for Jsplinter

There are two main reasons people ever use "char*" in C++: either they haven't learned std::string yet (meaning they are within a few weeks of having started to learn C/C++); or they are writing code that interfaces to a C library or an API written in C. If that is …

Member Avatar for Jsplinter
0
157
Member Avatar for nickx522

The point about reformatting is that you can spot mistakes in your code much more easily when the indentation is done properly. As a result, most programmers that have more than a few months of experience in coding are already fanatical about respecting format. It certainly won't magically fix any …

Member Avatar for WaltP
0
203
Member Avatar for Nathaniel10

>>Am I incrementing the address correctly or not? No. The problem is that the expression "&ch + i" takes the address for the pointer "ch" and increments that address by "i". Now, the address of the pointer "ch" is a pointer to a pointer to a char, i.e. "char**". Since …

Member Avatar for Nathaniel10
0
126
Member Avatar for slychronic

1. The function you are trying to implement is usually referred to as "concatenation" (or just "cat" for short). I'm just pointing that out to help you build a technical vocabulary for computer science. 2. There are already functions that implement this functionality. I'm sure you knew that, but just …

Member Avatar for mike_2000_17
0
163
Member Avatar for bejfake

This requires dynamic polymorphism (i.e. base class and some derived classes). A simple way to do it: [CODE] //a very simple base class with one virtual function (required for RTTI). struct stack_element { virtual ~stack_element() { }; }; //a general class template for holding a primitive value template <class T> …

Member Avatar for alwaysLearning0
0
3K
Member Avatar for jimbob90

The variables arr and maxVarHolder are already pointers to int, using the star * will dereference those into the int variable they point to. The stars are not correct. This will work: [CODE] result = sumarr(arr, num, maxVarHolder); [/CODE]

Member Avatar for mike_2000_17
0
232
Member Avatar for mitrious

The first thing you need to observe is "complexity". Intuitively, finding a random number between [0,n] shouldn't be much more complex whether n is smaller or greater than RAND_MAX. So, just a first look at your implementation reveals that something is wrong if the code is so much larger than …

Member Avatar for mitrious
0
106
Member Avatar for vijaykrishnabor

I found this quote to be quite nice about your topic: "An abstract function can have no functionality. You're basically saying, any child class MUST give their own version of this method, however it's too general to even try to implement in the parent class. A virtual function, is basically …

Member Avatar for mike_2000_17
0
134
Member Avatar for vijaykrishnabor

Basically, if the compiler wanted to inline a recursive function, it would be the equivalent to unrolling a loop. The first rule is that the number of recursions (or loops) has to be determined at compile time. So if your recursive function cannot be turned into a for-loop with a …

Member Avatar for mike_2000_17
0
2K
Member Avatar for alwaysLearning0

@firstPerson: read the question: "let's talk about template" and "How do you make this generic?", this is not a OOP or dynamic polymorphism question, but a question on generic programming and template meta-programming. Now to answer the (simple) question: this question is essentially generic programming 101. You can make a …

Member Avatar for mike_2000_17
0
185
Member Avatar for punchinello

The things between the colon and the curly brace is called the "initialization list". Read this [URL="http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6"]faq[/URL] on constructors for a good explanation on why this is preferable to assignments inside the body of the constructor.

Member Avatar for punchinello
0
133
Member Avatar for qinise4

>>is it possible to use mmap for this. Sure it's possible, but is it the best solution? mmap is a general one-size-fits-all solution for large data structures that are paged. It is most likely that your application can take advantage of the structure of your matrix and its usage to …

Member Avatar for qinise4
0
2K
Member Avatar for macla

I agree with Ketsuekiame, I don't see any reason why you would "automate" an install of a bunch of software on another computer. Remote desktop to it, or open a secure shell (ssh) to go in and transfer your installation executables (or packages) and run them. It is just as …

Member Avatar for macla
0
104
Member Avatar for baconswife

To turn this into a compilable and runnable program, use this: [CODE] #include <iostream> //this will include the "std::cout" stream for output to console. using namespace std; //this will allow you to avoid writing "std::" all the time. int mystery (int x, double y, char ch) { int u; if …

Member Avatar for mike_2000_17
0
1K
Member Avatar for Mona..

Just read this [URL="http://en.wikipedia.org/wiki/Perfect_number"]wiki[/URL]. There are three easy methods: sum all the number's proper divisors (those with modulus equal to zero) and check if it matches the number; generate one perfect number after another with the given formula until you go beyond the number; check if the bit pattern corresponds …

Member Avatar for mike_2000_17
0
83
Member Avatar for losh177

I agree with gerard, the std:: is missing for all uses of string and istream or ostream in the header file. Also, the #include <string.h> should be #include <string> because the former is a C library without std::string. **try to _only_ post the _relevant_ code**

Member Avatar for losh177
0
183
Member Avatar for Crucial

There are two functions that are _crucial_ for doing random access into a file stream, that is: tellg and seekg. The first will tell you at what position the reading pointer (g) is at the moment and the second will take that pointer to a previously recorded place (obtained from …

Member Avatar for mike_2000_17
0
184
Member Avatar for minnie19

You got the curly brackets a bit wrong: [CODE] #include <iostream> //omit the .h for the standard C++ libraries. //#include <stdlib.h> //stdlib.h is a C library that is not really used in C++. class fraction { //start the { just after the class name private: int den, num; //these are …

Member Avatar for minnie19
-1
305
Member Avatar for TayKaye

The one problem that I can see is the if you enter a number that is smaller than the first winning number, the search will drive the middle index to 0. And if the 0th value is still bigger than the number entered, "last" will be set to middle-1 which …

Member Avatar for TayKaye
0
491
Member Avatar for lelejau

It is dirty, but it is possible (everything is possible). I have no specific clue to give you but I can give you the basic strategy. First, [URL="http://www.akkadia.org/drepper/dsohowto.pdf"]this[/URL] is an interesting article on dynamic linked libraries (mainly written about Linux's "shared objects" which are the same as DLLs in windows), …

Member Avatar for mike_2000_17
0
1K
Member Avatar for cppgangster

**please use code tags in the future** The line "set_terminate(MyQuit);" should have been put inside the main() function. Just move it into main() and it will work.

Member Avatar for mike_2000_17
0
146
Member Avatar for sahil1991

I have never heard of graphics.h, I guess I am too young for that (I only started programming around the time win95 came out, so graphics.h was already outdated!). Here is [URL="http://www.daniweb.com/forums/thread17709.html"]another thread[/URL] with some useful info and links. I can't help any further, it appears you should try something …

Member Avatar for mike_2000_17
0
184
Member Avatar for mike_2000_17

Hey y'all, I have been working on a tensor library (Nth-order multi-dimensional arrays) and I've been having trouble coming up with a good scheme for a multi-dimensional iterator template. Basically, I have a class template "tensor_container" which stores all the values of the N-order array (as a std::vector of one …

Member Avatar for mike_2000_17
0
251
Member Avatar for Bigbrain99

First of all, the use of all-upper-case for class names is horrible. By convention, all-upper-case is reserved for #define (or MACROs). If this example was from a book, consider changing book. Now, about your question... first, observe the following: "string" is a class, just like "FLATMATE" is a class. So …

Member Avatar for Bigbrain99
0
103
Member Avatar for javanub123

I'm assuming you mean a graphical game (like 2D or 3D) because otherwise there is really nothing else you need besides a compiler and reasonable knowledge of C++. For either 2D or 3D, I find that OpenGL is a good place to start and the [URL="http://nehe.gamedev.net"]NeHe[/URL] tutorials are really easy …

Member Avatar for javanub123
0
217
Member Avatar for Nathaniel10

Yeah, definitely, this is what was expected to happen. The reason why you get so much iterations is because of virtual memory. You said you had 467K available... was that 467M, because if it is only 467K out of 1G, you should think of fixing something because I imagine your …

Member Avatar for Nathaniel10
0
1K

The End.