2,898 Posted Topics

Member Avatar for dvongrad

>>Sound simple? Not simple, but only a little twisted. I'll ignore the fact that "Sound simple?" is the only question you asked, and I'll go ahead and give you some hints by solving a similar problem. Long story short, the solution to your problem lies in "recursion" (a function that …

Member Avatar for dvongrad
0
308
Member Avatar for Frederick2

It seems you are doing the steps correctly (I'm not sure since I rarely use DLLs and Windows). To avoid the name-mangling problem. You need to make all your functions "extern "C"". This tells the compiler to use C name-mangling (which is basically no mangling at all). Every compiler has …

Member Avatar for Frederick2
0
692
Member Avatar for Transcendent

To do this in better style, you should do the following two changes: 1) Your line 33 should be: [CODE] const char* ThisOne = text.c_str(); [/CODE] And eliminating the declaration of ThisOne, earlier. 2) change all your parameter and return types from "char*" to "const char*". That should fix it. …

Member Avatar for mike_2000_17
0
328
Member Avatar for pseudorandom21

>>Can I use the new shared_ptr to access my class without worry, (assuming the instance won't be destroyed)? Yes. The "thread-safety" of shared_ptr has to do with modifying the pointer value stored in the shared_ptr. In that regard, the share_ptr has exactly the same thread-safety as a raw-pointer (which is …

Member Avatar for mike_2000_17
0
185
Member Avatar for i_luv_c++

There is one thing to observe. What is really expensive in your code (and in many linked-list implementation) is the very frequent dynamic allocation of memory of small chunks (each node). Because you know, from the start of this function, how much memory you will end up allocating for the …

Member Avatar for WolfPack
0
621
Member Avatar for stereomatching

You would need to pass "ref" and "out" by non-const reference. This also means that your call with bind will have to be supplied with non-temporary variables, e.g.: [CODE] ... template<typename inputItr, typename outputItr> void operator() (T const VALUE, inputItr[COLOR="Red"]&[/COLOR] ref, outputItr[COLOR="Red"]&[/COLOR] out) ... //I call the functor like this …

Member Avatar for mike_2000_17
0
228
Member Avatar for pato wlmc

>>so I didn't have to... build them(?) To help clarify, "building" is when you have a bigger project that requires several source files to be compiled into different building blocks (static libraries or shared libraries (DLL)) and then put altogether in a non-trivial way. That's all it means. Basically, it …

Member Avatar for pato wlmc
0
118
Member Avatar for daviddoria

>>Is the only overhead that I would have to then iterate through the image and delete all of the nodes when the image is destructed? I would hardly call that an overhead unless you are making new images and destroying old ones all the time. The real overhead is indirection …

Member Avatar for daviddoria
0
167
Member Avatar for Stefano Mtangoo

I am by no means an expert on these things, so the following is just an opinion. I think that the wikipedia section on [URL="http://en.wikipedia.org/wiki/GNU_General_Public_License#Linking_and_derived_works"]Linking and derived works[/URL] under GPL is pretty interesting. It seems to be a pretty vague issue. You also have to understand that licensing issues are …

Member Avatar for Stefano Mtangoo
0
452
Member Avatar for Lemonader

You do know that, in matlab, all you need to do to solve a linear system is to write [ICODE]x = A \ b;[/ICODE] where b is a column-vector and A is a square matrix. That's it, you don't need to use the function you posted (as I assume you …

Member Avatar for peter_budo
0
133
Member Avatar for spoonlicker

Snake game! That's funny, that was (almost) the first program I ever wrote, it was on my TI-83 calculator (the first programmable thing I ever put my hands on), I was about 13 years old and I did it in a few days' worth of spare time. It was a …

Member Avatar for kayhantolga
0
358
Member Avatar for lochnessmonster

C++ Standard 7.1.2/4 and 3.2/3 (One-definition Rule): [QUOTE]An inline function shall be defined in every translation unit in which it is used.[/QUOTE] In other words, all inline function (if the compiler so decides) have to be defined (have their implementation) in a header file (unless you want to get into …

Member Avatar for mike_2000_17
0
133
Member Avatar for Forthright

When a function is taking in a "const char*", it is only saying that it will not modify the data pointed to by that pointer. It doesn't mean that you are not allowed to change the data. In other words, a non-const pointer can be implicitly cast to a const …

Member Avatar for Forthright
0
346
Member Avatar for se00an

I have to say that your implementation of the backsub looks very bizarre. I have implemented back-substitution is several matrix numerical methods (PLU, QR, HH, Cholesky, SVD, etc.). I have checked them, and they look nothing like yours. Yours looks more like forward-substitution. First, your bounds at line 14 and …

Member Avatar for se00an
1
2K
Member Avatar for daviddoria

You could simply use the Boost.Function and Boost.Bind utilities, as follows: [CODE] class MyClass { public: double Update1(); double Update2(); double Update3(); boost::function< double() > Update; private: float Data1; ... float DataN; }; [/CODE] Then, define them as: [CODE] class MyClass { int UpdateMethod; }; void MyClass::SetUpdateMethod(int method) { if(method …

Member Avatar for mike_2000_17
0
110
Member Avatar for caut_baia

I agree with Narue, there is no escaping it. You have to implement the serialization method for each class. If you have a hierarchy of classes, then make it a virtual function and in each class you store its data only and call the base class method to serialize its …

Member Avatar for Labdabeta
0
653
Member Avatar for stompjrkz400

I would first verify with your teacher whether this is really what he wants, because that is not easy to do, in fact, you probably can't do it without an extended IO library (such as conio.h or curses.h). I would suggest you just avoid the problem and do this: [CODE] …

Member Avatar for Labdabeta
0
284
Member Avatar for Zjarek

This is an age old debate. C/C++ vs FORTRAN. Many people who know much more than I do have more informed opinions on it. I'm sure you can find many many forum threads, articles, and peer-reviewed research papers on the subject. However, you must be careful at only looking at …

Member Avatar for mike_2000_17
0
208
Member Avatar for atticusr5

Make sure you don't have an extra empty line at the end of your input file. I'm pretty sure that is the problem. And your original loop for file-reading is correct.

Member Avatar for atticusr5
0
182
Member Avatar for silverpanda

Well, there is a simple way to do it if you are restricted to iostream, cstring and cstdio. A simple modification of L7Sqr's code to use C-strings instead: [CODE] std::cout << "First names: "; char token[100]; std::cin.getline ( token, ',' ); std::cout << "Read token: " << token << std::endl; …

Member Avatar for jonsca
0
388
Member Avatar for kutuup

If your tutor told you that overloading the < operator for the Player class would make the tree ordered with respect to that comparison's logic, then he made a mistake in his implementation of the Tree class. This implementation of the Tree class compares the values of the pointers, not …

Member Avatar for mike_2000_17
0
130
Member Avatar for trebor-pl

If you look at my last answer to [URL="http://www.daniweb.com/forums/post1481779.html#post1481779"]this thread[/URL], you will see that you are in case number 5, i.e. you have an object hierarchy with cross-references between objects (via pointers). As with many programming problems there are three ways to solve it: the good, the bad and the …

Member Avatar for trebor-pl
0
1K
Member Avatar for ezat2020

[CODE] void _medianfilter(const.. [/CODE] Names with leading underscores are reserved by the C++ Standard article 17.4.3.1.2 for implementation-specific names in the global scope. It is not recommended to use names with leading underscores in any code that you write or use. If you need to "hide" a function, standard practice …

Member Avatar for ezat2020
0
188
Member Avatar for rbduck09

Well, I can help to make the description more concrete: gross income: Would be a number (int, float or double) that the user is asked for and will enter. itemized deduction: Would be an array of numbers (int, float or double) each representing a tax deduction amount. The taxpayer's deduction …

Member Avatar for rbduck09
-1
102
Member Avatar for super-duper

I think that at line 6, you meant to write: [CODE] while((ptr != NULL) && (item >= ptr->info) && (!found)) { [/CODE] Notice the >= at in the second comparison. Otherwise, this function will always output false. Hint: You should always turn on all the warnings when compiling. This code …

Member Avatar for super-duper
0
173
Member Avatar for Transcendent

Line 40, the single equal sign should be doubled == for comparison. Compiling with all warning on would have caught that typo (use -Wall as a compiler flag).

Member Avatar for mike_2000_17
0
146
Member Avatar for atticusr5

@NathanOliver: The <algorithm> version of sort cannot be used for the list container because it requires a random-access iterator (and list is a linked-list so it only provides a Forward and Backward Iterator concept). The way the OP did is correct. @atticusr: The sorting algorithm relies on the comparison (by …

Member Avatar for atticusr5
0
147
Member Avatar for Bill1811

You have, at line 17, a variable called "WriteResults". This is the same name as one of your functions. What happens is that this local variable "hides" the global function (because identifiers of local scope hide any identifiers of larger scope that happen to have the same name). So, at …

Member Avatar for mike_2000_17
0
179
Member Avatar for lochnessmonster

>>im trying to use the address,hardcoded at compile time, at that address, to read in the bytes starting at that address till the end of the return..... -thx ?????? If you want the "address hardcoded at compile time" that won't be of any use at run-time. At compile-time, all function …

Member Avatar for mike_2000_17
0
93
Member Avatar for daviddoria

The compiler "mike_2000_17" gives this error: "Error at line 34: function "GetOddElements" reaches end-of-scope without returning a value" The reason why your version that uses references is not working is because references are not copy-assignable, which is a requirement of all STL containers. As for the bigger question. This is …

Member Avatar for daviddoria
0
154
Member Avatar for spoonlicker

About pointers, there are two "alternatives" (the quote marks mean that they really can't completely replace pointers, but can significantly reduce the need for them). First, a very popular design pattern in C++ is RAII (Resource Allocation Is Initialization). This just means that when an object is created it initializes …

Member Avatar for katokato
-1
695
Member Avatar for writerervin

The only function that matters here is the changehp() function, and you didn't post it. Please do.

Member Avatar for writerervin
0
468
Member Avatar for Mr.UNOwen

If you are using GLUT for making the window, why not use it for the mouse and keyboard events too. It has all these things built into it. Look [URL="http://www.opengl.org/resources/libraries/glut/spec3/node45.html#SECTION00080000000000000000"]here[/URL]. Generally, the mouse events and keyboard events are intimately linked to the window context. So, that is why any library …

Member Avatar for Mr.UNOwen
0
189
Member Avatar for watery87

The strtok function: "A null pointer is returned if there are no tokens left to retrieve." You should handle that case. Possibly in your isValid() function (like a test for NULL before all the strcmp calls).

Member Avatar for mike_2000_17
0
162
Member Avatar for pato wlmc

>>The nice way, however is to create a class 'Student' and overload the >> operator, but for now the above should do fine. And the _easy_ way is to use std::getline() from the <string> header. As so: [CODE] string fullName; getline(cin,fullname); [/CODE] that will capture everything until the return key …

Member Avatar for WaltP
0
3K
Member Avatar for Lelly

>>>>Report the first, 1000th and last elements in your sorted list. >>It means, you need to sort the array, and print out the last 1000 items in the list. No, I think it means to print the first, 1000th and last elements. Say you have a std::vector named "my_sorted_array", once …

Member Avatar for mrnutty
0
532
Member Avatar for Tuloa

If you read [URL="http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml"]this doc[/URL], you will see that the width and height should be 1 if you want to read a single pixel. Second, the type parameter (which you have set to GL_BYTE) has to match the type of the pixel pointer which is GLfloat. So, that parameter should …

Member Avatar for mike_2000_17
0
571
Member Avatar for atticusr5

The insert function is only if you want to insert an element at a particular position in the list. For regular insertions of elements (at the end or at the beginning), you use the functions push_back() or push_front() (for inserting at the end or at the beginning, respectively). Basically, most …

Member Avatar for atticusr5
0
134
Member Avatar for pritpal.singh88

Well I'm not sure what exactly you want to do. To launch vlc, you just type vlc in the terminal. If you want to add a file (audio or video), you just put it as command-line argument to vlc. And, you can use "system" to write a command to the …

Member Avatar for ravenous
0
422
Member Avatar for spoonlicker

You'll have to be more precise. Mapping? What do you mean: - Mapping as in Map-Making (like Magellan!) - Mapping as in functional or topological mappings in mathematics - Mapping as in mapping some keys to some elements (as in std::map) - Mapping as in memory-mapped pointers - ....

Member Avatar for Nick Evan
-1
228
Member Avatar for lochnessmonster

There are many ways to mix C and C++. 1) It is very typical for external libraries to have C interfaces (API). There are many reasons why a C interface is chosen (or necessary). In that case, mixing C and C++ is required in order to use that external library, …

Member Avatar for pritpal.singh88
0
233
Member Avatar for lexusdominus

>>I don't learn any thing easy, and it usually takes me a LONG time to learn and understand things I had a friend who was just like that. He couldn't learn a thing without a _huge_ amount of explanation. Not so long ago, he went to a doctor and they …

Member Avatar for mike_2000_17
0
140
Member Avatar for spoonlicker

With GCC, all you need is the -S option: [CODE] $ gcc -S my_program.cpp [/CODE] It will create a file with the same name as the cpp file, but with extension .s and it contains the assembly listing (what you call machine language). If you are not using GCC, then …

Member Avatar for spoonlicker
0
3K
Member Avatar for caut_baia

Yes, your implementation of the deep-copy constructor seems totally fine (as long as the objects a pointing to objects of class A and not of a derived class, like I said in a previous thread). You probably want to also implement the assignment operator. operator = that is. Basically, it …

Member Avatar for caut_baia
0
3K
Member Avatar for COL_Milkshake

>>'BinarySearchTree::{ctor}' : constructors not allowed a return type If there is a return type, erase it. If there isn't a return type, then look at the code before the definition of the constructor to see if you made some mistake (like forgetting a closing bracket). There are several subtle errors …

Member Avatar for COL_Milkshake
0
3K
Member Avatar for twsmale

You can use the [URL="http://www.cplusplus.com/reference/string/getline/"]getline()[/URL] function. Notice in the link, that there is a parameter called delim which stands for a character that delimits your reading operation (it will stop reading in the string when it finds that character). By default, the delimiter is the newline character (and thus, the …

Member Avatar for twsmale
0
219
Member Avatar for pritpal.singh88

I think for encoding and decoding, you can use libmp3lame from the [URL="http://lame.sourceforge.net/"]LAME MP3 Project[/URL]. I have never used it so I don't know how to use it, but I'm sure that the basic idea is to decode from mp3 to an uncompressed format and feed it through [URL="http://connect.creativelabs.com/openal/default.aspx"]OpenAL[/URL] (what …

Member Avatar for mike_2000_17
-2
2K
Member Avatar for spoonlicker

You know there is this minimalist programming language called brainf*ck which is a Turing Complete language (i.e. you can program anytime you like with it) and it has 8 operators and only 1 variable... a pointer! So, even the smallest programming language in the world has pointers!

Member Avatar for papanyquiL
-5
233
Member Avatar for dolly_olaide

Line 49 is wrong for sure, it probably should be: [CODE] total += data[i*width + j]; //or maybe "data[j*height + i]" [/CODE] At line 62, the ImageData array was never initialized, so it won't contain the actual pixel values, you should probably use data as above. For the rest, I …

Member Avatar for dolly_olaide
0
5K
Member Avatar for poloblue

You don't have an implementation of setTime or getTime in the extClockType. The compiler assumes that the call refers to the setTime function in the base class ClockType and doesn't find a version of it with 4 parameters. Just implement a version of the setTime in the extClockType with the …

Member Avatar for Narue
0
311

The End.