2,898 Posted Topics

Member Avatar for akhal

Where are the fft and fft_rec function declared and defined? How are you compiling fft_test? Possible solution: mark the fft and fft_rec functions as 'inline' if they are defined in a header file.

Member Avatar for akhal
0
298
Member Avatar for David_Omid

I haven't gone through the code in detail, it is too much. But it looks to me like you are doing an exhaustive search of all possible future move sequences in a chess game. I could hardly expect this to finish running any time soon. It may not be an …

Member Avatar for David_Omid
0
168
Member Avatar for sha11e

You can achieve something reasonably close to what you want with this: [CODE] #include <iostream> #include <string> int main() { std::cout << "Hello"; std::string tmp; std::getline(std::cin,tmp,'\n'); std::cout << "there" << std::endl; return 0; }; [/CODE] This will just have the effect of printing the second part when the user presses …

Member Avatar for mike_2000_17
0
246
Member Avatar for montjoile

CodeBlocks on windows. KDevelop on Linux (Kubuntu). I agree with rubberman that IDEs can get in the way of effective coding (make you waste time on setting up projects and settings, and load times and stuff), but KDevelop is not one of those that do. It's by far the one …

Member Avatar for katmai539
0
126
Member Avatar for nocloud

You need to mark the dump2ivector function as const, like so: [CODE] void csv_File::dump2ivector(int column, vector<int> &data) const {....} //notice const at the end. [/CODE]

Member Avatar for mike_2000_17
0
202
Member Avatar for learningcpp

Yeah, you are correct. You will usually not gain anything at the end by trying to force the padding to not be done (if there is a way to do so). Usually, it will be much less efficient. If memory is really a problem, you might consider clustering several objects …

Member Avatar for mike_2000_17
0
174
Member Avatar for jackmaverick1

For booting, I would recommend you take and use the GRUB bootloader. Study it and figure out how to launch a kernel with it. Then, you can start making your own kernel. Start small and go incrementally. Making an OS is definitely one of the hardest things to do. Make …

Member Avatar for rubberman
0
200
Member Avatar for PixelatedKarma

You need some sort of use of windows API to catch keystrokes directly (including mod-states, like ctrl and shift). With win32 API, you need to make a [URL="http://www.toymaker.info/Games/html/wndproc.html"]WindowProc[/URL] function and handle the WM_KEYDOWN (Windows Message - Key-down event). Then, it is just a matter of writing a big switch-case statement …

Member Avatar for m4ster_r0shi
0
212
Member Avatar for powerdink

You have to think of iterators like pointers. The idea of iterators is to mimic this C-like for-loop: [CODE] int my_array[10]; //static array; for(int* ptr = my_array; //get a pointer to the start of the array. ptr != my_array + 10; //check that the pointer is not at the end …

Member Avatar for mike_2000_17
0
110
Member Avatar for lochnessmonster

Let me expand a little bit on this. COM (or Common Object Model) is essentially a "plugin" system. There are many variations or extensions to it, but the basic principle is to have a solution for the problem of interfacing Object-Oriented code, possibly programmed in different programming languages, distributed across …

Member Avatar for cppgangster
0
2K
Member Avatar for mrnutty

>>I need some explanation. Yep, at compile-time, because you call the function from a base-class pointer, the base-class function prototypes are looked at, the function "print" is found, the default parameter is picked up and inserted at the call-site. In other words, it becomes: [CODE] pb->print("wtf? -.-"); [/CODE] Then, at …

Member Avatar for Moschops
0
144
Member Avatar for Soulstorm

I don't know much about this subject, but I could suggest, as I often do, to consider Boost libraries. In this case, the multi-threading can be handled by Boost.Thread, and the asynchronous connections can be handled with [URL="http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio.html"]Boost.Asio[/URL] (Asynchronous IO library). As far as I know, they should be supported …

Member Avatar for mike_2000_17
0
154
Member Avatar for Labdabeta

Forget what sergent said, especially if you are using SDL or any other cross-platform GUI library. [URL="http://nehe.gamedev.net/"]OpenGL[/URL] is the way to go. GLUT and GLUI are also fairly feature-full as well. For a kick start, you can look at full-blown game renderers as well. For instance, [URL="http://www.ogre3d.org/"]Ogre3D[/URL] is a nice …

Member Avatar for dvidunis
0
249
Member Avatar for gingank

Visual C++ is an Integrated Development Environment (IDE) from Microsoft to program in C++. C++ is a programming language. There are many alternatives to Visual C++ as an IDE (and compiler). Visual C++ uses the microsoft compiler (MSVC for short). As of version 2010, the Microsoft compiler is pretty much …

Member Avatar for yoni0505
0
193
Member Avatar for sadsdw

I think you are going about this the wrong way. You should first think logically about what your program will have to do. Here is what I would say your program needs to do (at high level): 1) Read the IDs of the individual, and parents. 2) Create a record …

Member Avatar for sadsdw
0
120
Member Avatar for m4ster_r0shi

The problem is this line: [CODE] return insert_comma_helper( integer.substr(0, size - 3), result = integer.substr(size - 3, 3) + ',' + result); [/CODE] The reason why tail recursion is not done in this case is because you have temporary string variables in your recursive function call. That is the main …

Member Avatar for m4ster_r0shi
0
247
Member Avatar for Thisisnotanid

Just adding my grain of salt here. Disclaimer: these are all just my humble opinion... Personally, I use KDevelop. I find it to be awesome. The code highlighting is pleasant to the eye, the background parsing is fast, and code completion works very well. It is also fully integrated with …

Member Avatar for Moschops
0
238
Member Avatar for Vidgie65

Is this the Java forum? I'm confused... no, it is the C++ forum. Please post your code in the appropriate programming language for the forum! Whatever Random is, I assume it is a class that you wrote or your prof gave you as part of the assignment, because it is …

Member Avatar for mike_2000_17
0
383
Member Avatar for programing

I doubt very much that your teacher is really expecting you to write a "real" compiler in the sense that is produces machine code, because that requires much more than a theoretical idea of the inner workings of a compiler, it requires to know very low-level details about how to …

Member Avatar for rubberman
0
245
Member Avatar for trantran

I think you are very confused, no offence. It seems you don't understand the difference between an object and a class. An object is an instance of a class, in other words, the class is the type, and an object is a variable of that type. So, if you have …

Member Avatar for trantran
0
193
Member Avatar for king03

You don't have to use the letter 'i' for every for-loop variable. In fact, you shouldn't do that. You can pick any variable name you like, although it is idiomatic to use i,j,k,l.. letters, but that is just a convention. What you should not do is have several nested for-loops …

Member Avatar for Arbus
0
161
Member Avatar for Labdabeta

far and near are reserved keywords in C (not standard, but common, it is a relic from the times of 16bit architectures), it is generally not present in C++, but it's possible that your particular compiler uses it in C++ for compatibility with C. That's the only explanation I can …

Member Avatar for Salem
0
171
Member Avatar for UltimateKnight

>>How are the programs made so that they run with GUI interface and stuff like that? GUIs are made through the use of external libraries (either OS APIs or other (cross-platform) GUI libraries). Usually it is not really recommended to start making GUI applications until you have a pretty good …

Member Avatar for ichigo_cool
0
325
Member Avatar for akhal

Well, I think you need to brush-up on some complex algebra stuff... With Euler's identity, this e to the power of 2*Pi*j/n is simply a rotation by 2*Pi/n. You can easily construct this complex number by using the "polar" function, as so: [CODE] w = polar(1.0, 2*pi/n); [/CODE]

Member Avatar for akhal
0
325
Member Avatar for Labdabeta

There are several things wrong with your code. First, you have completely redundant pieces of code that clearly abuse dynamic memory allocation. As in this snippet: [CODE] float *temp=new float[numv*5]; for (int i=0; i<numv*5; i++) temp[i]=vars[i]; delete[]vars;vars=NULL; vars=new float[numv*5+5]; for (int i=0; i<numv*5; i++) vars[i]=temp[i]; delete[]temp;temp=NULL; [/CODE] You allocate, copy, …

Member Avatar for Labdabeta
0
156
Member Avatar for Freude

>>Other languages try to realize matrix data manipulation in correspondence with matrix theory. c++ is a little bit odd in this regard. Well, C++ does not try to realize matrix data manipulation at all. So, it is not surprising if it seems odd to you. Languages like Fortran and Matlab …

Member Avatar for mike_2000_17
0
189
Member Avatar for shadowscape

What Walt means is that the format in which you are getting the time string from strftime() is not the only one you can get. The string that is given to the function, i.e., "%d%m%Y%H%M%S", is what specifies how you want your date and time to look like in the …

Member Avatar for mike_2000_17
0
224
Member Avatar for montjoile

When doing [ICODE]malloc(sizeof(btree));[/ICODE], you are allocating enough memory to store a pointer to a node (that is was btree is, just a pointer to a node, not a node). That does not, in any way, allocate any memory to store the node content. When you are later accessing the node …

Member Avatar for montjoile
0
366
Member Avatar for iamthwee

I agree, the tic tac toe game is pretty trivial to solve. The set of possible situations a player can face is very limited. And, as firstPerson mentioned, if you write a decision tree for the optimal strategy, it is very simple and unbeatable, that's too easy. Typically, to really …

Member Avatar for pseudorandom21
0
178
Member Avatar for henrimontreal

**Please clean your code and use correct indentation when posting** Your teacher is correct. I don't really understand your question. First, unless you need a take the original string and turn all the letters into upper-case, I see no reason why you would need more than one string for this …

Member Avatar for mike_2000_17
0
159
Member Avatar for Mahkoe

Your code is valid, but it does nothing. You have the following in your code: - Declaration of a union type called 'un' (lines 1 to 6). - Declaration of a global variable called 'u1' of type 'un' (line 6). - Declaration of a global pointer called 'up' which is …

Member Avatar for Mahkoe
0
1K
Member Avatar for MareoRaft

You are not allowed to overload an operator for a built-in type (int, float, double, char, etc.). So, if your operator overload only involves built-in types, even if that operator doesn't exist yet for that type, it is illegal to do so. This is just a safe-guard built into C++ …

Member Avatar for NathanOliver
0
7K
Member Avatar for learningcpp

As Narue said, the top-level cv-qualifier is discarded in function calls. This is simply because, like in your example, when you pass-by-value, the top-level cv-qualifier of the original value doesn't and shouldn't matter, because it is copied to the function anyways. To fix the problem, simply make the parameter to …

Member Avatar for learningcpp
1
3K
Member Avatar for yashsaxena

Consider this simple example: [CODE] class Foo { public: virtual void f(); //one virtual function virtual void g() = 0; //one pure-virtual function }; class Bar : public Foo { public: virtual void f(); //overridden virtual void g(); //overridden virtual void h(); //one additional virtual function }; [/CODE] Now, class …

Member Avatar for yashsaxena
0
217
Member Avatar for nocloud

The "initialization list" is what you need. This should, in fact, be used to initialize all your data members and base-classes, if possible. Here is a simple example: [CODE] mem_data::mem_data(int a,int b,std::string c) : mem_store(a), complete(b), date_file(c) { }; [/CODE] That's it. What is between the colon and the opening …

Member Avatar for mike_2000_17
0
278
Member Avatar for Labdabeta

The only things that matter between glNewList and glEndList are the OpenGL calls, and they get "frozen" (because they are compiled on the GPU). Any logic conditional statements or whatever can be used to create the OpenGL calls, but once they are created, that's it. DisplayLists themselves cannot record any …

Member Avatar for Labdabeta
0
241
Member Avatar for Labdabeta

The math is very simple. Take the difference between two pair of points (like pt2 - pt1, and pt3 - pt1) to get two vectors, take the [URL="http://en.wikipedia.org/wiki/Cross_product"]cross-product[/URL] of the vectors, and normalize it. That's it. In other words: [CODE] void GenerateNormal(float x[3], float y[3], float z[3], float &ox, float …

Member Avatar for Labdabeta
0
126
Member Avatar for lochnessmonster

Well, obviously, your example is a straw-man, you would not want to upcast in that case. One of the main points of Object-Oriented Programming is the concept of Polymorphism, which entirely relies on upcasting and virtual member functions. If you are not familiar with virtual functions, it is almost pointless …

Member Avatar for thekashyap
0
189
Member Avatar for ichigo_cool

The assign function is used to completely overwrite the entire content of the vector. The overload that you are using (with an integer first and an element value second) is the overload that interprets the first parameter as the number of elements in the new vector content, and the second …

Member Avatar for ichigo_cool
0
197
Member Avatar for montjoile

You are right. A typedef is nothing more than a new name for a type, in that sense, it is an alias. And, it really is just a new name for a type, not a new type in and of itself. It serves the purpose of shortening names to make …

Member Avatar for montjoile
0
145
Member Avatar for I Like Pills

I think you are asking the wrong question. Programming is a tool. Asking if people get bored of programming is like asking a plumber if he gets bored of using a wrench, he would probably tell you that his job is not about using a wrench but about helping people …

Member Avatar for pseudorandom21
0
370
Member Avatar for Saith

First of all, you should only seed the random number generator once, not everytime you call rand(). So, you should seed the RNG in the constructor of randomInteger. Second, to obtain a random number between 0 and some max-value, you can just use the modulus operator %. As so: [CODE] …

Member Avatar for Saith
0
337
Member Avatar for lochnessmonster

That's just how processors are built. When one talks about the "natural word size" of an architecture, it relates to the size of the registers and the granularity of memory addressing. CPUs are expected to spend the greatest part of their time doing operations on numbers of the natural word …

Member Avatar for mike_2000_17
0
128
Member Avatar for milan2011

Your use of exception specifications is well intended, but impractical, especially for a generic class. In Herb Sutter's words, [URL="http://www.gotw.ca/gotw/082.htm"]"Don't bother. Even experts don't bother."[/URL]. The same goes for [URL="http://www.boost.org/development/requirements.html#Exception-specification"]Boost developers[/URL]. [URL="http://www.gotw.ca/publications/mill22.htm"]Here[/URL] is an in-depth look at this issue. Just don't do it. Second, whenever making generic types, you should …

Member Avatar for mike_2000_17
0
167
Member Avatar for cppgangster

Your error doesn't say that NumericOperation does not exist. The error says that, at line 47, there is an "illegal use of an incomplete type". Forward declarations don't allow you to use the type/class directly, it allows you to use complete types which are related to that forward-declared type. Pointers …

Member Avatar for cppgangster
0
114
Member Avatar for Sky Diploma

As far as I know, under windows, bluetooth is provided by [URL="http://msdn.microsoft.com/en-us/library/aa362932(v=vs.85).aspx"]native OS APIs[/URL] (either Bluetooth-specific functions, or through Windows Sockets). Of course, it requires that you link against "Bthprops.lib". MinGW and GCC have work-arounds to be able to link to libraries not compiled with GCC, but it is most …

Member Avatar for mike_2000_17
0
1K
Member Avatar for JordanHam

Well, plotting a graph implies a GUI, and most GUI tools have at least basic plotting tools. One that can easily be advocated is the used [URL="http://qt.nokia.com/products/"]Qt[/URL] for the GUI and [URL="http://qwt.sourceforge.net/"]Qwt[/URL] for the scientific plotting tools. If you just want to have a plot, no GUI, I would suggest …

Member Avatar for ravenous
0
278
Member Avatar for Stefano Mtangoo

>>But I cannot get hold of how OGL maps its coordinates system with respect to the screen of the computer. This is done via something called the [URL="http://www.songho.ca/opengl/gl_projectionmatrix.html"]Projection Matrix[/URL]. It is quite a simple transformation from 3D cartesian coordinates to a 3D projective geometry (which produces 2D screen coordinates and …

Member Avatar for Stefano Mtangoo
0
206
Member Avatar for Saad234

A DLL is a Dynamic Link Library. It is essentially a collection of compiled functions that can be called from another executable (or another DLL). So, instead of compiling your C++ code into a executable, you compile it into a DLL with a set of functions that you want to …

Member Avatar for mrnutty
0
233
Member Avatar for martin111

A pointer to a derived class and a pointer to a base class, for the same object, are not guaranteed to hold the same address in memory. Often, they do, but sometimes they don't. For example, when using virtual inheritance and/or multiple inheritance, then, for the same object, the pointers …

Member Avatar for mike_2000_17
0
302

The End.