Forum: C++ 21 Hours Ago |
| Replies: 1 Views: 54 Re: UDP-Sockets chat application question First, is this the "best" way to tackle the chat problem?
no. it is unlikely that someone would want to set up a chat between two processes on the same machine, sharing stdin and stdout between... |
Forum: C++ 21 Hours Ago |
| Replies: 3 Views: 58 Re: error dynamic_cast in c++ you need to enable RTTI. (use compiler switches for this.)
either you have turned it off by using the switch /GR-
or you are using a fairly old version of the microsoft compiler.
turn it on with the... |
Forum: C++ 2 Days Ago |
| Replies: 1 Views: 74 |
Forum: C++ 2 Days Ago |
| Replies: 2 Views: 77 Re: Creating a memory mapped file > man mmap <Enter>
at the command prompt on your system. it should give you all the information that you require.you would see something like this:... |
Forum: C++ 4 Days Ago |
| Replies: 3 Views: 90 Re: Hiding an Assignment Operator > declare it as private and just leave an empty implementation?
ideally, declare it as private and do not define it.
> Is this common/useful?
useful, yes. common, not all that much.
if there is a... |
Forum: C++ 4 Days Ago |
| Replies: 2 Views: 348 Re: How to download file from internet? > It keeps saying:
> Failed to connect with the server : Bad file descriptor
that says all that needs to be said, doesn't it?
int websock; // websock is an uninitialized int
webaddress.sin_family =... |
Forum: C++ 11 Days Ago |
| Replies: 7 Views: 189 Re: overload << for a base class struct base
{
virtual std::ostream& write( std::ostream& stm ) const = 0 ;
// ...
};
inline std::ostream& operator<< ( std::ostream& stm, const base& object )
{
return object.write( stm ) ;... |
Forum: C++ 13 Days Ago |
| Replies: 3 Views: 143 |
Forum: C++ 14 Days Ago |
| Replies: 1 Views: 92 Re: Help with Explicit parameter polymorhphism have a look at the standard header <utility>. it defines std::pair and std::make_pair.
template <typename First, typename Second>
struct Pair
{
First f;
Second s;
Pair( const First& ff,... |
Forum: C++ 18 Days Ago |
| Replies: 1 Views: 154 Re: Hack Tool Development bulk rename of all the .wav files in one go and updating the text in all the .phr files at another time can leave you in a messy state in the event of a crash (you would have to restart all over... |
Forum: C++ Sep 28th, 2008 |
| Replies: 6 Views: 332 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++ Sep 28th, 2008 |
| Replies: 11 Views: 456 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++ Sep 26th, 2008 |
| Replies: 2 Views: 152 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++ Sep 26th, 2008 |
| Replies: 2 Views: 158 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++ Sep 26th, 2008 |
| Replies: 9 Views: 316 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++ Sep 26th, 2008 |
| Replies: 9 Views: 316 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++ Sep 26th, 2008 |
| Replies: 7 Views: 241 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++ Sep 26th, 2008 |
| Replies: 9 Views: 316 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++ Sep 17th, 2008 |
| Replies: 4 Views: 368 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++ Sep 17th, 2008 |
| Replies: 7 Views: 373 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++ Sep 17th, 2008 |
| Replies: 2 Views: 199 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++ Sep 16th, 2008 |
| Replies: 14 Views: 560 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++ Sep 16th, 2008 |
| Replies: 4 Views: 288 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++ Sep 16th, 2008 |
| Replies: 8 Views: 325 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++ Sep 16th, 2008 |
| Replies: 14 Views: 560 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++ Sep 16th, 2008 |
| Replies: 9 Views: 390 |
Forum: C++ Aug 31st, 2008 |
| Replies: 1 Views: 218 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: 876 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: 240 |
Forum: C++ Aug 29th, 2008 |
| Replies: 6 Views: 318 |
Forum: C++ Aug 28th, 2008 |
| Replies: 3 Views: 229 |
Forum: C++ Aug 28th, 2008 |
| Replies: 15 Views: 1,392 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: 229 |
Forum: C++ Aug 27th, 2008 |
| Replies: 15 Views: 1,392 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: 325 |
Forum: C++ Aug 25th, 2008 |
| Replies: 9 Views: 338 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: 220 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: 532 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: 338 |
Forum: C++ Aug 18th, 2008 |
| Replies: 7 Views: 368 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... |