2,898 Posted Topics

Member Avatar for Karlwakim

>>Is it possible to write a c++ compiler in c++ ? Well, the [URL="http://gcc.gnu.org/wiki/CppConventions"]steering committee of GCC[/URL] believe so. I don't know of any compiler that is entire written in C++, but it is certainly possible. The only problem is that compilers need to be rock solid, meaning that you …

Member Avatar for vijayan121
0
198
Member Avatar for BCBTP

What you are describing is just a typical commercial license, with the only difference that you are not charging a price for getting the program (i.e. freeware). But that's still a commercial license, you can charge the price you want for any of the three distributions (app, libs, or source), …

Member Avatar for vijayan121
0
198
Member Avatar for daviddoria

Well from the link, the assignment operator requirement is only for "output iterators" where the expression [ICODE]*it = a;[/ICODE] must be valid. BTW, the iterators for the std::set container are not output iterators. So, that shouldn't be a problem. But iterators are not all, you need to watch out for …

Member Avatar for mike_2000_17
0
170
Member Avatar for daviddoria

The main problem, of course, with the code you posted is that the indirect_iterator class implements the assignment operator in terms of an assignment operation on the pointees, not the pointers. Because indirect_iterator was made with the assumption that it should behave exactly as if the iterator was an ordinary …

Member Avatar for mike_2000_17
0
212
Member Avatar for mrnobody

If you make functions that are re-entrant (or almost pure-functional) then you don't have to worry about anything. The main characteristic of a re-entrant function is that it has no dependence whatsoever on data from outside the function (excluding the input variables of course, and read-only access to global (quasi-)constants), …

Member Avatar for rubberman
0
143
Member Avatar for PeTo.

[URL="http://www.cplusplus.com/reference/stl/set/"]std::set[/URL] is a standard container that doesn't allow for duplicates. So, you can just do this: [CODE] #include <set> #include <cstdlib> #include <ctime> int main() { srand((unsigned)time(0)); std::set<int> numbers; while( numbers.size() < 4 ) numbers.insert( rand() % 10 ); return 0; }; [/CODE]

Member Avatar for adityatandon
0
2K
Member Avatar for Amina Mishu

You should start by finding the [URL="http://en.wikipedia.org/wiki/Differential_%28infinitesimal%29"]total differential[/URL] of your formula. Then, computing it is a trivial matter with minimal knowledge of C++.

Member Avatar for adityatandon
0
117
Member Avatar for mrnobody

You specified your global variable with the keyword "static" which means that the global variable is local to the compilation unit it which it appears (a compilation unit is one compiled .cpp file). This means that the "global" variable Result that appears in "DisplayResult.cpp" is not the same as the …

Member Avatar for mrnobody
0
248
Member Avatar for pseudorandom21

I'm not an expert with boost.spirit, but I don't think that it makes much sense to specify a delimiter which has "any number of spaces" as in the delimiter generator expression [ICODE](*(karma::space) << ',' << *(karma::space))[/ICODE]. This is likely to be the explanation for the infinite loop (probably the star …

Member Avatar for mike_2000_17
0
191
Member Avatar for nuclear

The problem stems from the fact that you use a very bad integration method for you acceleration. Here are some basics about motion: If [I]p[/I] is the position of an object, and that object is travelling at a constant speed [I]v[/I], then, at time [I]t[/I], the object will be at …

Member Avatar for mike_2000_17
0
152
Member Avatar for sergent

>>I know that by default member functions of a class are inlined If member functions are defined within the class declaration, then yes, it is implicitly assumed to have been declared with the [ICODE]inline[/ICODE] keyword. Whether it will be inlined by the compiler is another question that only compiler-vendors can …

Member Avatar for mike_2000_17
0
220
Member Avatar for Clinton Portis
Re: :)

[CODE] #include <iostream> int main() { for(int i = 0; i < 3; ++i) std::cout << "Ho! "; return 0; }; [/CODE]

Member Avatar for mrnutty
3
116
Member Avatar for kbar1

Here are some good suggestions of algorithms to implement for practice that are a bit more substantive than those suggested already, grouped by topics of scientific computing, most of which are fundamental algorithms that are very relevant in practice too. I also noted rough line-of-code counts (assuming you don't implement …

Member Avatar for mike_2000_17
0
161
Member Avatar for ben1996123
Member Avatar for Moschops
0
560
Member Avatar for kris kannan

It all depends on what kind of image processing tasks you need to do. The best place to start is probably [URL="http://opencv.willowgarage.com/wiki/"]OpenCV[/URL]. I'm sure it's possible to at least try to get it working on a DSP (with uCLinux for example). Otherwise, you can at least have access to the …

Member Avatar for kris kannan
0
419
Member Avatar for Tigerwatch

>>By the way, I'm using dark gdk which has some simple collision detection tools by itself. though when i use the code to detect collision for objects, the program just skips over it without doing any thing. it doesn't even any errors. I suggest you review the documentation on dark …

Member Avatar for Tigerwatch
0
162
Member Avatar for Labdabeta

1) If you are not going to put anything in DllMain than you might as well remove it. 2) It seems you have made your DLL compatible with C, or at least, tried. If you really want compatibility with C, you cannot use references. If you will always compile the …

Member Avatar for Labdabeta
0
155
Member Avatar for Labdabeta

It seems to me that this piece of code is suspicious, in the "highlight" function, towards the end, you have: [CODE] char *temp=new char[len(text)+108]; sprintf(temp,"<table width=\"100%%\" border=\"0\" cellspacing=\"0\">\n<tr>\n<td>1.</td>\n<td bgcolor=\"#FFFFFF\">%s</span></td>\n</tr>\n</table>",text); [/CODE] I counted 116 additional characters (considering the newlines to be one character, which is not the case on all OSes). …

Member Avatar for mike_2000_17
0
242
Member Avatar for NoUserNameHere
Member Avatar for zbar

Well, the line "getch();" is going to wait for the user to type a character before exiting the program. Remove it and the program will exit after printing "End of file!" and the console window will close.

Member Avatar for tapaninyc
0
3K
Member Avatar for stereomatching

In a similar fashion as gusano79 has suggested, you can use a templated wrapper to reduce the amount of coding necessary for the different wrappers. Here is what I mean: [CODE] class Airplane { public: virtual void fly() = 0; virtual void speed_up() = 0; }; template <typename AirplaneType, void …

Member Avatar for stereomatching
0
106
Member Avatar for thanatos1

You should remove the [ICODE]Shape::[/ICODE] in front of each function name within the declaration of the Circle or Triangle classes, you don't need that and should have it there (and that's the error your compiler reports).

Member Avatar for mike_2000_17
0
252
Member Avatar for Rez11

The prototype of displayGame needs to match its definition _exactly_. So you need this prototype instead (at the beginning): [CODE] void displayGame(Game[], int); [/CODE]

Member Avatar for dan1865
0
198
Member Avatar for Zssffssz

>> Would the last line work? No. >> Or do I have to declare a vareable to do any math/calculations? Yes, you can do computations to obtain the initialization value of a global variable, but you cannot do general statements. >> Does it execute in a top down fashion? Yes, …

Member Avatar for mike_2000_17
0
165
Member Avatar for bkoper16

Quick answer: remove the [ICODE]template <class T>[/ICODE] on lines 59 and 67. Long answer: The problem here is that you are defining, in the general class template, two function template (operators << and >>). Then, in the specialization, you define a friend function. For a moment, forget the whole business …

Member Avatar for bkoper16
0
1K
Member Avatar for camelNotation

Why not use an embedded accessor class: [CODE] class PersonalInfo { private: int ID; string Name; public: struct Accessor { int& ID; string& Name; Accessor(PersonalInfo& Host) : ID(Host.ID), Name(Host.Name) { }; }; struct constAccessor { const int& ID; const string& Name; constAccessor(const PersonalInfo& Host) : ID(Host.ID), Name(Host.Name) { }; }; …

Member Avatar for tekbhatta
1
2K
Member Avatar for BoBok2002

First of all, the loading of the texture and the registering of it to OpenGL only has to occur once. So, you should move the call to LoadGLTextures() to the init function. All that you need to do before you render the polygons on which the texture is applied is …

Member Avatar for BoBok2002
0
1K
Member Avatar for jeevsmyd

Well, of course, AD and firstPerson's answers clearly doesn't do what you want. vijayan121's answer is probably as much as you'll be able to do, that is, make the return type into whatever type that is common to both operand types. Which, again, isn't exactly what you want. And, in …

Member Avatar for mike_2000_17
0
225
Member Avatar for theprofoundgeek

If you use the clock() function, it will return the clock ticks elapsed by your process only. My guess is that you have been using a general local-time function like "time()" to measure your elapsed times. The time() function and the clock() function are fundamentally different in the sense that …

Member Avatar for ExpertsGuide
0
322
Member Avatar for woody363

Hi woody363, To install Qt, you can simply install qt-creator (the main IDE for Qt). Here are the detailed instruction to install that: 1) Go to a terminal window. 2) Type this (the dollar sign not included): [CODE] $ sudo apt-get install qtcreator qtcreator-doc [/CODE] 3) Enjoy (the Qt Creator …

Member Avatar for woody363
0
296
Member Avatar for stereomatching

Boost.Spirit should be used. Boost.Spirit is the library that allows you to create a grammar and do parsing / generation of XML data. The purpose of Boost.Serialization is very different, it is true that it can interact with XML to do the serialiation / unserialization, but it isn't a parsing …

Member Avatar for stereomatching
0
348
Member Avatar for Zssffssz

To add to vijayan121's great explanation. Although nice, the <chrono> header doesn't solve the problem of the epoch of reference, it is still implementation-defined, which is a good thing in general, but a problem, of course, if you want some type of absolute reference. The [URL="http://www.boost.org/doc/libs/1_48_0/doc/html/date_time.html"]Boost.Date-Time[/URL] library is a good …

Member Avatar for vijayan121
0
885
Member Avatar for deliezer

>>The compiler plainly doesn't allow this. Basically, the restriction that is imposed on the default arguments (for function parameters) is that they cannot be derived from or referring to the other function parameters. And because the "this" pointer is a hidden first argument to any class member function, any non-static …

Member Avatar for deliezer
0
137
Member Avatar for SSight3

>> The above code (on the GCC compiler) creates the problem where TestB doesn't actually call TestB's constructor, I does call the TestB constructor, just not the one you defined but the default, compiler-generated copy-constructor. If you don't provide a constructor of the form [ICODE]TestB(const TextB&)[/ICODE], the compiler will generate …

Member Avatar for SSight3
0
300
Member Avatar for atiyehjoon

>> What are ostream & istream and what do they do? ostream stands for output stream, and istream stands for input stream. They are base classes that define the interface for any input/output stream. All the stream objects in the C++ standard library derive from one of these base classes …

Member Avatar for mike_2000_17
0
217
Member Avatar for stereomatching

What you are describing is a build script, that is what you need. Personally, I am not familiar with Visual C++'s build system and the possibilities it offers to write build scripts. The main reason I'm not familiar with it is because it generally sucks and most large cross-platform projects …

Member Avatar for stereomatching
0
195
Member Avatar for PrimePackster

Well. Maybe WaltP has 1 in 50 chance of finding the error, but I have an eagle eye and a compiler built into my brain, which means I have a 100% chance of finding the error. And the error is at this line in your loop: [CODE] sum1++=p; [/CODE] You …

Member Avatar for PrimePackster
0
103
Member Avatar for stereomatching

The Boost.MPL is a great tool for template meta-programming. It basically contains an entire compile-time implementation of the STL containers and algorithms. So, yes, there are plenty of alternatives to loki::Typelist. In MPL terms, these are [URL="http://www.boost.org/doc/libs/1_47_0/libs/mpl/doc/refmanual/sequences.html"]Sequences[/URL]. You can choose, like with STL containers, whether you want random-access or not, …

Member Avatar for mike_2000_17
0
1K
Member Avatar for beaute

Sure. The important thing is that you make sure that both have the same calling convention. If your DLL function was compiled with another calling convention, then that's the calling convention that you should have for your function-pointer type "pICFUNC". BTW, the default calling convention in C/C++ is "__cdecl" on …

Member Avatar for mike_2000_17
0
145
Member Avatar for awesome_cool

>> I've been Programming in C++ for a year. I am done with Basics and all other OOP concepts(like inheritance,polymorphism and STL) That's funny. I've probably said that (i.e. "I am done with ... ") every year since I started programming (13 years ago or so), but it was always …

Member Avatar for thines01
0
529
Member Avatar for That_Dude

If you want to stick to C++, and remain cross-platform, I would just suggest you use [URL="http://qwt.sourceforge.net/"]Qwt[/URL] (add-on to Qt). The image on their home-page is a Bode plot, so I'm pretty sure you can use that library for your purpose. If you don't absolutely need C++, then Matlab or …

Member Avatar for mike_2000_17
0
725
Member Avatar for alarifth

Whenever you provide default parameters for a function (whether a constructor or otherwise) they should appear in the declaration of the function, not in its definition. In other words, your constructor declaration (in header file) should be: [CODE] public: Person(string first = "", string second = ""); [/CODE] And your …

Member Avatar for mzimmers
0
10K
Member Avatar for ChaseRLewis

It is quite intriguing indeed. Maybe you should try to also print out the counts on the allocate calls. So far, I don't know what would cause the double allocate, especially since it doesn't match the number of deallocate calls, that is even more disturbing in my opinion (I say …

Member Avatar for vijayan121
0
151
Member Avatar for megatron21

Simple typo: [CODE] if (r=y && c==x){ [/CODE] should be: [CODE] if (r == y && c == x){ [/CODE] (notice the double = signs. **Please use code-tags in the future.

Member Avatar for megatron21
0
256
Member Avatar for David321

>>What is the point of a static method? The point of a static method is that it can access all the private members of the class but isn't tied to an object (instance of the class). I would agree that it isn't the most useful thing in the world. One …

Member Avatar for mike_2000_17
0
161
Member Avatar for bjwittrock

First of all, I don't know if the implementation of "Matrix" class is special, but normally, in C/C++, the indices (i,j) go from 0 to N-1, not from 1 to N (like in Matlab or Fortran). If this Matrix class is implemented to handled 1-based indices, then I highly recommend …

Member Avatar for mike_2000_17
0
212
Member Avatar for Zssffssz

First of all, [URL="http://www.daniweb.com/software-development/cpp/threads/391439/1686649"]this thread[/URL] should answer all your questions about what a DLL is and what is meant by "dynamic-link". Now, for a simple example of a DLL, here is the simplest example I can think of, the "hello world" program: In hello_world.h: [CODE] #ifndef HELLO_WORLD_H #define HELLO_WORLD_H #ifdef …

Member Avatar for mike_2000_17
0
327
Member Avatar for janejackson87

>>care to expand? I tend to think of data hiding as a likely consequence of encapsulation. In a similar sense that encapsulation is the bundling of data and behaviour in a single entity, I usually also attach to that the presence of some form of hiding the details (like the …

Member Avatar for mike_2000_17
0
202
Member Avatar for myk45

First, the obvious, in both cases, you have compiled code, so it is all a matter of linking and loading. In all cases, a .lib file is a static-link library, meaning that it is used by the linker to complete all the function calls that exist in your application that …

Member Avatar for myk45
0
914
Member Avatar for rjstamey

You can simply store your objects in a vector, that is, you can do: [CODE] #include <iostream> #include <string> #include <vector> using namespace std; class record { public: string name; string bankAccountNum; double accountBalance; void output(); }; int main() { //create a vector container of customers: vector<record> customers; record customer; …

Member Avatar for xfbs
0
479

The End.