Forum: C++ 14 Days Ago |
| Replies: 6 Views: 197 Re: wired knapsack... the general knapsack problem and the subset sum problem are NP-hard, but not NP-incomplete. so there are no polynomial-time algorithms. but it is one of the easy NP-complete problems to solve.
it... |
Forum: C++ 14 Days Ago |
| Replies: 11 Views: 354 Re: Const Question - Why is this happening? this is nothing specific to constructors or passing parameters to functions.
it is just the application of the C++ rules for resolving a call to an overloaded function.
#include <iostream>
void... |
Forum: C++ 16 Days Ago |
| Replies: 2 Views: 104 Re: a few questions about C++ source code > #pragma - what does it mean
to understand what #pragma is see: http://msdn.microsoft.com/en-us/library/d9x1s805(vs.71).aspx
for the specific #pragma directives that are in your code, refer to your... |
Forum: C++ 16 Days Ago |
| Replies: 2 Views: 98 Re: Container Adapter Confusion have each of the two stacks to store a reference to a std::deque.
initialize them to refer to the same std::deque.
write a wrapper class to hold the two stacks.
template< typename T > struct... |
Forum: C++ 16 Days Ago |
| Replies: 9 Views: 218 Re: Fast Conversions writing a convert function (with construction and destruction of a stringstream each time it is called) would give more maintainable code. even in this case, the performance seems to be... |
Forum: C++ 16 Days Ago |
| Replies: 9 Views: 218 Re: Fast Conversions only because the language the OP is using ( MessageBox::Show ) is C++/CLI (not ISO C++).
and purely managed will not give anywhere near native performance. |
Forum: C++ 16 Days Ago |
| Replies: 7 Views: 154 Re: help with stream files in adition, change int size = 100; to const int size = 100;
size of an array must be a constant known at compile time. |
Forum: C++ 16 Days Ago |
| Replies: 9 Views: 218 Re: Fast Conversions > What I look for now is a fast way to convert from double to char*
> I have a problem to find this conversion.
a. compile C++ source to generate native code, not IL that is interpreted at run-time.... |
Forum: C++ 25 Days Ago |
| Replies: 4 Views: 274 Re: Constructor function call problem consider using the std::tr1 polymorphic function wrappers. this would allow using free functions, member functions and function objects in a polymorphic way.
if your compiler does not ship with tr1,... |
Forum: C++ 25 Days Ago |
| Replies: 7 Views: 269 Re: template function overloading > But I still find it ackward, that there are no possibility to do it.
> I can handle special cases when, I have different INPARS as long as the method is void.
> But it's not possible to do it when... |
Forum: C++ 25 Days Ago |
| Replies: 2 Views: 107 Re: Need help using shared_ptr a std::tr1::shared_ptr cannot correctly hold a pointer to a dynamically allocated array. AFAIK, there is no such smart pointer in tr1.
you could use boost::shared_array (tr2) instead.... |
Forum: C++ 26 Days Ago |
| Replies: 14 Views: 444 Re: this pointer > the self-assignment test does not work well in class hierarchies either,
> even with use of boost::addressof().
it is unlikely that using value semantics on object-oriented types is something... |
Forum: C++ 26 Days Ago |
| Replies: 4 Views: 203 Re: Rounding function perhaps the easiest way is to use the iostream formatted output facilities:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
int main()
{
double a = 2.5632, b = 2.5652 ; |
Forum: C++ 26 Days Ago |
| Replies: 8 Views: 264 Re: Arguments and strings a little less verbose, and a little more efficient:
#include <vector>
#include <string>
int main ( int argc, char** argv )
{
std::vector< std::string > arguments( argv, argv+argc ) ;
} |
Forum: C++ 26 Days Ago |
| Replies: 14 Views: 444 Re: this pointer >> The above is common practice, but it is easily broken.
>> Imagine, for example, a class that supports its own operator&() ...
>> The most useful way I've found to do an assignment operator is;... |
Forum: C++ 26 Days Ago |
| Replies: 9 Views: 278 |
Forum: C++ Aug 31st, 2008 |
| Replies: 1 Views: 150 Re: Problem with destructor > As a destructor releases memory for an object ...
a destructor does not release memory. it deinitializes an object and after it executes, what is left is uninitialized memory (earlier occupied by... |
Forum: C++ Aug 31st, 2008 |
| Replies: 8 Views: 596 Re: shift (bitshift) through char array > i would like to avoid doing 4 times 2 shift for each char.
> For each char i do 4 shift operations and 4 bitwise AND's, thats 8 bitwise operations.
you can reduce it to just 4 AND operations by... |
Forum: C++ Aug 29th, 2008 |
| Replies: 7 Views: 183 |
Forum: C++ Aug 29th, 2008 |
| Replies: 6 Views: 235 |
Forum: C++ Aug 28th, 2008 |
| Replies: 3 Views: 191 |
Forum: C++ Aug 28th, 2008 |
| Replies: 15 Views: 935 Re: Array with Variable Size in a Structure measurements for the same snippet (3 each) for the microsoft compilers:
compiler: VC++ 9.0 (Express 2008)
optimizations: /Ox /Ob2 /Oi /Ot /Oy /GT /GL
processor: Intel Pentium M 1.86 GHz
c array:... |
Forum: C++ Aug 28th, 2008 |
| Replies: 3 Views: 191 |
Forum: C++ Aug 27th, 2008 |
| Replies: 15 Views: 935 Re: Array with Variable Size in a Structure valarrays were introduced with the idea that it might encourage C++ compiler developers for vector processors to implement them as built-in types (the compiler could emit code to optimize the use of... |
Forum: C++ Aug 25th, 2008 |
| Replies: 6 Views: 239 |
Forum: C++ Aug 25th, 2008 |
| Replies: 9 Views: 279 Re: algorithmic problem... any 3-combination of the N-set would consist of numbers at 3 different positions in the array; you could choose positions i,j,k out of these three such that i<j<k holds.
so doesn't the problem... |
Forum: C++ Aug 24th, 2008 |
| Replies: 3 Views: 181 Re: Search Function Troubles > Could it be because i am entering the string 'key' with spaces?
yes
> how would i fix it?
use std::getline
http://www.cppreference.com/cppstring/getline.html |
Forum: C++ Aug 23rd, 2008 |
| Replies: 3 Views: 399 Re: union vs reinterpret_cast<>() > Is there any real different between using an union between two types and a reinterpret_cast between two types
yes, there are quite a lot of differences.
a union reinterprets the layout of memory... |
Forum: C++ Aug 21st, 2008 |
| Replies: 3 Views: 248 |
Forum: C++ Aug 18th, 2008 |
| Replies: 7 Views: 291 Re: "Taking an address" see IS 9.4.2/4
GCC is conforming. static constant member object is 'used' (in main) and, therefore, has to be defined.
the main issue here is that if you take the address, the static object has... |
Forum: C++ Aug 18th, 2008 |
| Replies: 4 Views: 206 |
Forum: C++ Aug 18th, 2008 |
| Replies: 2 Views: 222 |
Forum: C++ Aug 15th, 2008 |
| Replies: 13 Views: 558 |
Forum: C++ Aug 14th, 2008 |
| Replies: 3 Views: 279 |
Forum: C++ Aug 14th, 2008 |
| Replies: 6 Views: 223 Re: My class is not a modifiable lvalue? Point B(); is the declaration of a function called 'B' which takes no arguments and returns a Point.
modify to Point B ; and you have the definition of a variable called 'B' which is of type Point... |
Forum: C++ Aug 9th, 2008 |
| Replies: 6 Views: 349 |
Forum: C++ Aug 8th, 2008 |
| Replies: 2 Views: 170 Re: Need help with cards project... to just draw 52 cards in random order without duplicate draws, just fill an array/vector of size 52 with values [1,52] and do a std::random_shuffle on it.
to make 52 draws, marking/discarding... |
Forum: C++ Aug 8th, 2008 |
| Replies: 7 Views: 356 Re: Review: small recursive code to reproduce the white spaces in the original in the reversed sentence:
#include <string>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <ctype.h>
template< typename... |
Forum: C++ Jul 19th, 2008 |
| Replies: 1 Views: 263 Re: problem with template of a generic datatype the error is this: error C2993: 'float' : illegal type for non-type template parameter 'zero'
non-type template parameters are restricted to
a. constant integral values (including enumerations)
b.... |
Forum: C++ Jul 18th, 2008 |
| Replies: 5 Views: 475 Re: calculate the amount of heap memory > Windows heap is not the same thing as CRT heap
and to complicate matters, there may be several win32 heaps (and several CRT heaps) in a process.
if an exe or shared object (DLL) is linked with... |