1,247 Posted Topics

Member Avatar for MedianHansen

(most) windows programs are written to run against an environment subsystem. the subsystem is specified in the PE header of the executable image and is placed there by the linker. currently, your program is being linked with the linker switch [B]/SUBSYSTEM:WINDOWS[/B]. this implies that your program does not require a …

Member Avatar for SgtMe
0
939
Member Avatar for PennKen2009

> where each column vector is normally distributed, between -1 and +1, and the row vectors are uniformly distributed between -1 and +1 this is mathematically impossible. if row vectors are uniformly distributed between -1 and +1, any element in any row (read any element in your 2d array) is …

Member Avatar for zati
0
759
Member Avatar for casperguru

[ICODE]void foo(int* a)[/ICODE] and [ICODE]void foo(int a[])[/ICODE] are identical; they are not distinguishable from each other. they are the same [ICODE]void foo(int(&a) [N])[/ICODE] [B]a[/B] is a reference to an array of exactly [B]N[/B] elements. disadvantage: [B]N[/B] must be a constant known at compile time. advantage: size of the array is …

Member Avatar for C++NOOOB
0
297
Member Avatar for Covinus

[quote=jbennet;386884]Also bear in mind that some old versions of turbo c++ and nearly all versions of Visual Studio do not adhere to the standard[/quote]the c++ front-end from Edison Design Group is the [B]only[/B] implementation to support the complete C++ standard ISO/IEC 14882:2003. see: [url]http://www.edg.com/index.php?location=c_lang[/url] a good test for compiler conformance …

Member Avatar for Tom Gunn
1
1K
Member Avatar for vijayan121

a string which can be used ala std::string, preserves case, but comparisons are not case sensitive.

Member Avatar for ~s.o.s~
0
462
Member Avatar for vijayan121

choose a random element from a sequence when a. you do not know how many elements are there before hand b. you want to make one single pass through the sequence c. you do not want to use auxiliary storage

0
734
Member Avatar for Cosa
Member Avatar for Dave Sinkula
0
118
Member Avatar for DarkNova

you could write a custom allocator that tracks calls to allocate and deallocate. [code=c++]#include <map> template< typename T > struct myallocator : public std::allocator<T> { typedef std::allocator<T> base ; typedef typename base::size_type size_type; typedef typename base::difference_type difference_type; typedef typename base::pointer pointer; typedef typename base::const_pointer const_pointer; typedef typename base::reference reference; typedef …

Member Avatar for ggsddu
0
2K
Member Avatar for kemarS

you could use [ICODE]boost::progress_display[/ICODE] [url]http://www.boost.org/libs/timer/timer.htm[/url] [code=c++]#include <boost/progress.hpp> #include <iostream> #include <unistd.h> int main() { enum { LINES_IN_FILE = 1000 } ; boost::progress_display display( LINES_IN_FILE, std::cout ) ; for( int i=0 ; i<LINES_IN_FILE ; ++i ) { // process one line, add to database usleep( 10 ) ; // simulate taking …

Member Avatar for daviddoria
0
132
Member Avatar for jonathanasdf

> ...maybe the array is automatically cleared from memory when the application closes... right, provided your program is running under an os ( like unix, windows, linux ... ) which gives a separate virtual address space for each process. when a process terminates, all the resources it owns are reclaimed …

Member Avatar for fskreuz
0
133
Member Avatar for jaepi

normally, you would not try to write a web server yourself. instead you would host your web application inside an application server like apache or IIS. and let that take care of not merely threading, but also a lot of other issues which need to be addressed (security, cookie management, …

Member Avatar for smitz
0
123
Member Avatar for bling_bling_vr6

[quote=bling_bling_vr6;345628]... but I'm stuck on how to avoid filling it with duplicate values. I'm assuming that i'll have to use either a linear or binary search function while filling the array...[/quote] 1. you cannot do a binary search; the array is not ordered. 2. a linear search is possible, but …

Member Avatar for kitf84
0
3K
Member Avatar for littlestone

you can answer this yourself if you write a small test program and run it. for example: [code=c++]#include <iostream> struct A { A() { std::cout << "A::default constructor\n" ; } A( const A& ) { std::cout << "A::copy constructor\n" ; } A& operator= ( const A& ) { std::cout << …

Member Avatar for abhijitm
0
212
Member Avatar for spikeglow

> can u pass template class objects as parameters to friend functions of the same class?? obviously, you can. but you need to let the compiler know that they are templates. [code=c++]#include <iostream> // declare things first template< typename T > class array ; template< typename T > std::istream& operator>> …

Member Avatar for vijayan121
0
417
Member Avatar for gammavn

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 compiler switch /GR [url]http://msdn.microsoft.com/en-us/library/we6hfdy0.aspx[/url]

Member Avatar for vijayan121
0
189
Member Avatar for KDan

[B]> man mmap[/B] <Enter> at the command prompt on your system. it should give you all the information that you require.you would see something like this: [url]http://www.freebsd.org/cgi/man.cgi?query=mmap&apropos=0&sektion=0&manpath=FreeBSD+7.0-stable&format=html[/url]

Member Avatar for james_zheng
0
191
Member Avatar for AutoC

read the following pages and you should be ok: [url]http://www.relisoft.com/science/CrcMath.html[/url] [url]http://www.relisoft.com/science/CrcNaive.html[/url] [url]http://en.wikipedia.org/wiki/Cyclic_redundancy_check#Computation_of_CRC[/url] [url]http://www.relisoft.com/science/CrcOptim.html[/url]

Member Avatar for vijayan121
0
157
Member Avatar for skatamatic

> 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 class that you write (for example a window), and want its instances not to …

Member Avatar for wt1099
0
312
Member Avatar for Vux

> It keeps saying: > Failed to connect with the server : Bad file descriptor that says all that needs to be said, doesn't it? [code]int websock; [COLOR="Red"]// websock is an uninitialized int[/COLOR] webaddress.sin_family = AF_INET; webaddress.sin_addr.s_addr = inet_addr("http://www.google.com/index.html"); webaddress.sin_port = htons(80); if(connect(websock, ... [COLOR="Red"]// websock is not a file …

Member Avatar for vijayan121
0
789
Member Avatar for daviddoria

[CODE=C++]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 ) ; // polymorphic } // ---------------------------------------------------------------------------------------------------- struct derived : base { // override virtual std::ostream& write( std::ostream& stm ) …

Member Avatar for Lerner
0
187
Member Avatar for monogana

[QUOTE][code=cplusplus] template <typename C> typename C::iterator SlowFind(C& c, const typename C::value_type& v) { typename C::iterator i; for (i = c.begin(); i != c.end() && *i != v; ++i) ; return i; } [/code][/QUOTE] this is broken when C is a const container. c.begin() and c.end() returns objects of type C::const_iterator. …

Member Avatar for monogana
0
174
Member Avatar for vladdy191

have a look at the standard header <utility>. it defines std::pair and std::make_pair. [CODE=c++98]template <typename First, typename Second> struct Pair { First f; Second s; Pair( const First& ff, const Second& ss ) : f(ff), s(ss) {} // etc }; template <typename First, typename Second> inline Pair<First,Second> makePair( const First& …

Member Avatar for vijayan121
0
140
Member Avatar for Dave Sinkula

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 again after restoring from backups). you could consider …

Member Avatar for vijayan121
0
215
Member Avatar for lmastex

in adition, change [ICODE]int size = 100;[/ICODE] to [ICODE][COLOR="Red"]const[/COLOR] int size = 100;[/ICODE] size of an array must be a constant known at compile time.

Member Avatar for lmastex
0
123
Member Avatar for VernonDozier

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. [code=c++]#include <iostream> void foobar( int& arg ) { std::cout << "foobar( int& )\n" ; } void foobar( const int& arg ) { …

Member Avatar for VernonDozier
0
424
Member Avatar for gregorynoob

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 can be solved (in pseudo-polynomial time) using dynamic programming. AFAIK, using a Branch and bound algorithm [url]http://en.wikipedia.org/wiki/Branch_and_bound[/url] should …

Member Avatar for VernonDozier
0
272
Member Avatar for Jennifer84

> 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. b. enable optimizations. with these two, this is what i …

Member Avatar for mitrmkar
0
154
Member Avatar for mac1234mac

> #pragma - what does it mean to understand what #pragma is see: [url]http://msdn.microsoft.com/en-us/library/d9x1s805(vs.71).aspx[/url] for the specific #pragma directives that are in your code, refer to your compiler docs. > what does word __fastcall mean __fastcall is an implementation-defined keyword in microsoft and several other compilers. it specifies a particular …

Member Avatar for stilllearning
0
168
Member Avatar for Yuruke

have each of the two stacks to store a [B]reference[/B] to a std::deque. initialize them to refer to the [B]same[/B] std::deque. write a wrapper class to hold the two stacks. [code=C++]template< typename T > struct dual_stack { struct first_stack { explicit first_stack( std::deque<T>& seq ) : sequence(seq) {} // implement …

Member Avatar for stilllearning
0
119
Member Avatar for wolih

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, you can use boost::function in the interim. [url]http://www.boost.org/doc/libs/1_36_0/doc/html/function/tutorial.html#id2903300[/url] [code=c++]#include <iostream> #include <string> #include <map> #include <vector> // tr1: #include <functional> …

Member Avatar for wolih
0
139
Member Avatar for monkey_king

> 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 you have a return type. you can get …

Member Avatar for monkey_king
0
112
Member Avatar for Moschops

a [ICODE]std::tr1::shared_ptr[/ICODE] 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. [url]http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/shared_array.htm[/url] [ICODE]std::tr1::shared_ptr[/ICODE] to a [ICODE]std::vector[/ICODE] is a far more flexible alternative.

Member Avatar for Moschops
0
166
Member Avatar for jadedman

for the predefined streams, it's safe to mix C stdio and C++ iostreams. you can safely use [ICODE]stdin[/ICODE] and [ICODE]std::cin[/ICODE] in the same program; the C++ Standard guarantees that it will work the way you would expect it to. if you don't need to mix C stdio and C++ iostreams …

Member Avatar for Jawahar prabhu
0
1K
Member Avatar for coveredinflies

>> 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; >> ... >> the only cost is associated with creating a temporary copy of …

Member Avatar for vijayan121
0
191
Member Avatar for grisha83

perhaps the easiest way is to use the iostream formatted output facilities: [code=c++]#include <iostream> #include <string> #include <sstream> #include <iomanip> int main() { double a = 2.5632, b = 2.5652 ; std::ostringstream strout ; strout << std::fixed << std::showpoint << std::setprecision(2) << "a: " << a << " b: " …

Member Avatar for vijayan121
0
105
Member Avatar for iamthwee

a little less verbose, and a little more efficient: [CODE=C++]#include <vector> #include <string> int main ( int argc, char** argv ) { std::vector< std::string > arguments( argv, argv+argc ) ; } [/CODE]

Member Avatar for vijayan121
0
92
Member Avatar for monkey_king

> 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 using 4 bit masks. [code=c++]#include <iostream> #include <limits> int …

Member Avatar for monkey_king
0
2K
Member Avatar for kneiel

> 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 the object, whose lifetime is now over). how (or if) this memory is released depends on the …

Member Avatar for vijayan121
0
85
Member Avatar for DigitalPackrat

also have a look at codeville [url]http://codeville.org/[/url] it is one one of the easiest to use.

Member Avatar for DigitalPackrat
0
202
Member Avatar for tracethepath

> while(fin) is running endlessly .. in general, when reading an entire file, it is a good idea to embed the input statement inside the while loop's condition. this would eliminate a lot of subtle errors. and the loop will exit once eof is reached. eg. [code=c++]#include <fstream> int main() …

Member Avatar for udayasankar
0
9K
Member Avatar for salman1354

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 the vector pipeline). See Bjarne Stroustrup, "The C++ Programming Language: Third Edition", Chapter 22 Numerics, Section 4 Vector …

Member Avatar for grumpier
0
267
Member Avatar for Gentile

if you absolutely need a base class Chart (with virtual functions), a hack would be to overload the AddElement function. i would prefer using templates for your containers as suggested by Narue in the other thread. and as for this issue: > ... generic template<class T> container and have a …

Member Avatar for vijayan121
0
118
Member Avatar for gregorynoob

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 reduce to generating all unique 3-combinations of an N-set. several algorithms to do this efficiently exist. Chase's …

Member Avatar for gregorynoob
0
172
Member Avatar for kneiel

[CODE]Derived d; Base *p = reinterpret_cast< Base*>(&d); [/CODE] > 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 offset of zero in the derived class object. do not get lulled into a false …

Member Avatar for Alex Edwards
0
174
Member Avatar for alpine89

> Could it be because i am entering the string 'key' with spaces? yes > how would i fix it? use [ICODE]std::getline[/ICODE] [url]http://www.cppreference.com/cppstring/getline.html[/url]

Member Avatar for ArkM
0
200
Member Avatar for Alex Edwards

> 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 (depending on which member is accessed). a reinterpret_cast is a conversion operator. the conversions that can …

Member Avatar for vijayan121
0
2K
Member Avatar for DigitalPackrat
Member Avatar for DigitalPackrat
0
160
Member Avatar for Alex Edwards

see IS 9.4.2/4 [QUOTE]"...The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition shall not contain an initializer".[/QUOTE] GCC is conforming. static constant member object is 'used' (in main) and, therefore, has to be defined. the main issue …

Member Avatar for vijayan121
0
1K
Member Avatar for Alex Edwards

Stan Lippman's Inside the C++ Object Model [url]http://www.amazon.com/Inside-Object-Model-Stanley-Lippman/dp/0201834545[/url]

Member Avatar for Alex Edwards
0
162
Member Avatar for conan19870619

The End.