Forum: C++ Nov 20th, 2008 |
| Replies: 5 Views: 2,173 > i read somewhere that sockets are full duplex, so initially i tried to build an architecture like this:
a socket is *one* end of a two-way communications link.
a BSD socket maintains a separate... |
Forum: C++ Nov 16th, 2008 |
| Replies: 1 Views: 388 read the following pages and you should be ok:
http://www.relisoft.com/science/CrcMath.html
http://www.relisoft.com/science/CrcNaive.html... |
Forum: C++ Nov 13th, 2008 |
| Replies: 3 Views: 651 > 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... |
Forum: C++ Nov 13th, 2008 |
| Replies: 2 Views: 4,490 > 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
... |
Forum: C++ Sep 28th, 2008 |
| Replies: 11 Views: 1,171 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: 9 Views: 746 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 16th, 2008 |
| Replies: 9 Views: 1,152 for the predefined streams, it's safe to mix C stdio and C++ iostreams. you can safely use stdin and std::cin in the same program; the C++ Standard guarantees that it will work the way you would... |
Forum: C++ Aug 25th, 2008 |
| Replies: 6 Views: 899 Derived d;
Base *p = reinterpret_cast< Base*>(&d);
> I found that this is also legal--
it will compile.
it will work correctly if and only if the anonymous base class sub-object is at an... |
Forum: C++ Aug 23rd, 2008 |
| Replies: 3 Views: 1,706 > 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 18th, 2008 |
| Replies: 4 Views: 669 Stan Lippman's Inside the C++ Object Model
http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545 |
Forum: C++ Aug 8th, 2008 |
| Replies: 7 Views: 1,342 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 17th, 2008 |
| Replies: 8 Views: 793 > The structs are padded so that no padding occurs when we create an array of them,
> like with a scalar variable because if the compiler padded the struct when it created the
> array it wouldn't... |
Forum: C++ Jul 17th, 2008 |
| Replies: 8 Views: 816 #include <iostream>
#include <limits>
// addition can be done using bitwise xor
// with adjustments for carry bits
unsigned int plus( unsigned int first, unsigned int second )
{
unsigned... |
Forum: C++ Jul 16th, 2008 |
| Replies: 22 Views: 1,873 > The address of a constructor shall not be taken.
> - I am not getting it.
perhaps this snippet will explain this (and a few other things about constructors):
namespace A
{
enum COLOUR {}... |
Forum: C++ Jul 11th, 2008 |
| Replies: 2 Views: 475 from http://www.gnu.org/software/make/manual/make.html#Implicit-Rules |
Forum: C++ Jul 6th, 2008 |
| Replies: 13 Views: 1,384 > What compiler are you using?
the non-conforming code compiles on gcc 4.1 (which is known to be non-conforming with respect to template template parameters).
gcc 4.2 and gcc 4.3 correctly gives... |
Forum: C++ Jul 5th, 2008 |
| Replies: 9 Views: 2,227 for a standard container, begin() and end() are overloaded on the const specifier.
on a modifiable container, begin() and end() return container::iterator.
on a const container, begin() and end()... |
Forum: C++ Jul 3rd, 2008 |
| Replies: 9 Views: 844 to enforce const-correctness (a good idea), use const as required. eg.
#include <cstddef>
struct Piece ;
struct board
{
enum { N = 8 } ; |
Forum: C++ Jun 27th, 2008 |
| Replies: 5 Views: 1,289 asynchronous write to a file by aio_write http://www.freebsd.org/cgi/man.cgi?query=aio_write&apropos=0&sektion=2&manpath=FreeBSD+7.0-stable&format=html is POSIX.1, and should work on linux. |
Forum: C++ Jun 1st, 2008 |
| Replies: 3 Views: 2,412 sortValues is not a template member. you need to modify DO_SORT
#define DO_SORT(varName, a, b, c, d) (*(varName)).sortValues(a, b, c, d)
when you are sorting an array of char, use MySort<char>... |
Forum: C++ May 29th, 2008 |
| Replies: 4 Views: 417 for( int i=0 ; i<10 ; ++i )
numb2[i] = i%2 == 0 ? (i/2)*5 : i ; |
Forum: C++ May 27th, 2008 |
| Replies: 21 Views: 34,633 > ...probably some gcc/g++ extension that was messing things up
> (which is obviously the only real possibility here).
it is not some gcc/g++ extension; it is POSIX
man pause... |
Forum: C May 16th, 2008 |
| Replies: 8 Views: 1,642 > i try to avoid copying anything than 2 pointers...
swapping pointers is easy; swap pointers to arrays just like you swap any other pointers.
#include <stdio.h>
void swap( int rows, int cols,... |
Forum: C++ May 10th, 2008 |
| Replies: 6 Views: 846 c++98 has the convenient std::pair<>.
c++09 also has std::tuple<>.
#include <utility>
#include <algorithm>
#include <tuple>
std::pair<int,int> min_n_max( const int* arr, std::size_t N )
{
... |
Forum: C++ May 7th, 2008 |
| Replies: 5 Views: 1,933 > Is there anything that 'wraps' pipes?
i do not know of any, but it is very easy to roll out one of our own. eg.
#include <stdio.h>
#include <boost/iostreams/device/file_descriptor.hpp>
#include... |
Forum: C++ Apr 26th, 2008 |
| Replies: 9 Views: 3,280 the C library clock() does not give the wall clock:
just sleeping or waiting for input will work for time() (which gives the wall time), not for clock(); no processor time is used by the process... |
Forum: C++ Apr 18th, 2008 |
| Replies: 6 Views: 1,000 > I would like to be able to read from pipe in child so I know what parent has sent.
> How to do this ...
the simplest way would be to use read and write on the anonymous pipe.
man read(2)... |
Forum: C++ Apr 17th, 2008 |
| Replies: 11 Views: 1,505 > a different program to read from that file BEFORE the first program is finished writing to it.
the output to a file is buffered at many levels: by the fstreambuf of the c++ library and by the... |
Forum: C++ Apr 15th, 2008 |
| Replies: 2 Views: 5,795 boost::algorithm::split works like std::strtok. delimiters that are just single characters.
use boost::algorithm::split_regex to split character sequences where delimiters are regular expressions.... |
Forum: C++ Mar 24th, 2008 |
| Replies: 2 Views: 435 > what is the problem
the problem is that string b; creates an empty string. b[j]=a[i]; is incorrect; there are no characters in b.
> i want the first character on string a to be the last char... |
Forum: C++ Mar 23rd, 2008 |
| Replies: 6 Views: 4,632 if you want to iterate through a sequence container erasing elements as you go along, you must use the return value of container::erase. the return value is a vald iterator that designates the first... |
Forum: C++ Mar 21st, 2008 |
| Replies: 6 Views: 868 > ... but it doesn't really pose a problem here ...
this
ofstream newOccupant;
if(AuthorizeEntry(IDcard,lot))
{
cout<<"Lot Accessed." <<endl;
if(lot == 'A') |
Forum: C++ Mar 17th, 2008 |
| Replies: 5 Views: 49,815 > I was creating the derived class method definitions in a cpp file
> and couldn't get the project to progressively compile correctly.
> At my first method definition, a default constructor,
> the... |
Forum: C++ Mar 15th, 2008 |
| Replies: 32 Views: 6,201 even if you do not have a store for all primes < 100 (you do need an array or vector for that), you can use the knowledge that even numbers greater than 2 are not prime. and cut the number of times... |
Forum: C++ Mar 12th, 2008 |
| Replies: 1 Views: 823 you are encountering the strange behaviour because of this function (ideally it should not have compiled at all):
bool validity_check(int level,int n, int current[])
{
for(int... |
Forum: C++ Mar 12th, 2008 |
| Replies: 5 Views: 1,875 were you looking for a standard library function?
like std::accumulate ( in header <numeric> )
// vec is a std::vector<int> and N <= vec.size()
int sum = std::accumulate( vec.begin(),... |
Forum: C++ Mar 6th, 2008 |
| Replies: 26 Views: 5,937 ok. here is what you need to do.
download the following files:
http://www.agentpp.com/snmp++v3.2.23.tar.gz
http://www.agentpp.com/libdes-l-4.01a.tar.gz
http://www.agentpp.com/msvc7.zip
extract... |
Forum: C++ Mar 5th, 2008 |
| Replies: 10 Views: 1,150 it is impossible to say just by looking at the fragments you posted. this one seems interesting.
> since this following code runs flawlessly while moving the snake around, there must not be a... |
Forum: C++ Feb 23rd, 2008 |
| Replies: 40 Views: 2,374 yes. something like
int max_so_far = array[0] ;
for( int i=1 ; i<num_elements ; ++i )
{
// if the element in question is greater than max_so_far, make
// max_so_far equal to that element... |
Forum: C++ Feb 20th, 2008 |
| Replies: 7 Views: 1,581 > I heard something that boost's preprocessor library can do that.
> didn't get to try it out : http://boost.org/libs/preprocessor/doc/ref/repeat.html.
BOOST_PP_REPEAT gives a fast horizontal... |