1,247 Posted Topics

Member Avatar for zzmgd6

the problem is discussed in this thread: [url]http://www.daniweb.com/forums/thread115838.html[/url]

Member Avatar for vijayan121
0
263
Member Avatar for zoner7

[code]//... case 2: cout << "what is the title of the game you would like to remove?\n"; cin >> game; myIterator = find( games.begin(), games.end(), game ) ; if ( [COLOR="Red"]myIterator != games.end()[/COLOR] ) { games.erase(myIterator); } break; // ...[/code]

Member Avatar for vijayan121
0
94
Member Avatar for brk235

[LIST=1] [*]you could have name as a non-static member in the class. this can be used to give a name to each object. [*]you could use an enum or a variable to give a name (identifier) for a position in the array. [*]you could create an alias (reference) with a …

Member Avatar for vijayan121
0
104
Member Avatar for timdog345
Member Avatar for timdog345
0
84
Member Avatar for WesFox13
Member Avatar for jrkeller27

>> I'm guessing using whitespace and periods as delimiters as the parameters, >> but how do I use both delimiters at the same time. as dragon has shown, using whitespaces alone as delimiters is very easy; this is the default in c++. to also use period, ; , :, ? …

Member Avatar for William Hemsworth
0
1K
Member Avatar for WondererAbu

> how to link classes with each other? classes are types. are you looking for how to implement a typelist? a tutorial introduction to typelists: [url]http://www.ddj.com/cpp/184403813?_requestid=1305388[/url] you might then want to read Alexandrescu's Modern C++ Design (Addison-Wesley Longman, 2001). and look up Boost.MPL [url]http://www.boost.org/doc/libs/1_35_0/libs/mpl/doc/index.html[/url] which has a ready made framework …

Member Avatar for Cybulski
0
154
Member Avatar for varsha0702

> So I want to know is it possible to compile a code in such a way that if it is compiled > on RHEL 5 machine, same compiled code should work on any other Linux distros? the problem is caused by changes in the ELF binary format between RHEL4/FC5 …

Member Avatar for vijayan121
0
162
Member Avatar for TheGhost

[code]for(it = aMap.begin(); it != aMap.end(); it++){ //some processing if(//some condition){ //some processing aMap.erase(key); [COLOR="Red"]// this is undefined behaviour // the iterator is invalid after the erase[/COLOR] it--; } }[/code] this will work on conforming implementations: [code]it = aMap.begin() ; while( it != aMap.end() ) { //some processing if(some_condition) { …

Member Avatar for TheGhost
0
129
Member Avatar for Black Magic

using c++09 variadic templates [url]http://www.osl.iu.edu/~dgregor/cpp/variadic-templates.pdf[/url] [code=c++09]#include <iostream> template < typename T > T largest( T first, T second ) { return first > second ? first : second ; } template < typename T, typename... U > T largest( T first, U... rest ) { return largest( first, largest( rest... …

Member Avatar for n.aggel
0
151
Member Avatar for ara_neko25

to make one line of your ladder: [code=c++]#include <string> std::string make_line( char X, std::size_t num_chars, std::size_t num_spaces_on_left ) { const char space = ' ' ; return std::string( num_spaces_on_left, space ) + std::string( num_chars, X ) ; }[/code]

Member Avatar for Salem
0
113
Member Avatar for n.aggel

> i try to avoid copying anything than 2 pointers... swapping pointers is easy; swap pointers to arrays just like you swap any other pointers. [code=c99]#include <stdio.h> void swap( int rows, int cols, float (**after)[rows][cols] , float (**before)[rows][cols] ) { float (*temp)[rows][cols] = *after ; *after = *before ; *before …

Member Avatar for n.aggel
0
378
Member Avatar for monstro

this is what the C++ standard specifies about the layout (note that there are no separate specifications for struct and class) [QUOTE]Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses within a class object. The order of allocation …

Member Avatar for Duoas
0
185
Member Avatar for putagunta

> Shouldn't "this" inside CMeasurement::getSumMethodName have the same value as &meas? not necessarily. if getSumMethodName is a function inherited from a base class (in a multiple inheritance scenario) and the base class is at a non-zero offset, the this pointer in the function should point to the base class sub-object …

Member Avatar for putagunta
0
85
Member Avatar for monstro

> is it possible to declare a windows CRITICAL_SECTION object as a member of a base class > that will not be created for each derived class? yes > Does this look like a reasonable way to implement CRITICAL_SECTION yes, this is the normal way when you want to synchronize …

Member Avatar for monstro
0
199
Member Avatar for picass0

[code=c++]#include <string> #include <vector> #include <fstream> typedef unsigned char byte ; void bwt_encode( byte* buf_in, byte* buf_out, int size, int* primary_index ) ; void bwt_decode( byte* buf_in, byte* buf_out, int size, int primary_index ) ; int main() { std::ifstream fin("Dec of Ind.txt") ; std::string word ; while( std::getline(fin,word) ) { …

Member Avatar for vijayan121
0
147
Member Avatar for n.aggel

> is there any way to use threads in c++ the ISO standards committee (c++09) has voted voted in a number of concurrency extensions into the working draft (memory model, atomics library, basic threads, locks, and condition variables). an asynchronous future<T> type would be added later, but features like thread …

Member Avatar for n.aggel
0
173
Member Avatar for kux

> Is there any standard function to test the endianess of the system? [code=c++]inline bool little_endian() { union { long i ; char c[ sizeof(long) ] ; }; i = 1 ; return c[0] == 1 ; }[/code]

Member Avatar for Salem
0
195
Member Avatar for mbarriault

have a look at the source code for Boost.multi_array [url]http://www.boost.org/doc/libs/1_35_0/libs/multi_array/doc/index.html[/url] [url]http://www.boost.org/doc/libs/1_35_0/libs/multi_array/doc/user.html#sec_access[/url]

Member Avatar for mbarriault
0
83
Member Avatar for Blondeamon

> Should i just take Dijkstra or Kruskal that i have already coded and add the vertice weights into the game ? that would not work. Kruskal does something like this create a set containing all the edges in the graph ... remove an edge with minimum weight from the …

Member Avatar for Blondeamon
0
121
Member Avatar for savinki
Member Avatar for hmaich

with [code]class Rectangle { //... public: //... Rectangle operator +(Rectangle); //... };[/code] // a, b, c are Rectangles [ICODE]a = b + c ;[/ICODE] evaluates to [ICODE]a = b.operator+(c) ;[/ICODE] since [ICODE]c[/ICODE] is passed by value, a copy of [ICODE]c[/ICODE] is made (and destroyed later). the return value is an …

Member Avatar for Duoas
0
120
Member Avatar for ardeth32

[url]http://www.comp.dit.ie/rlawlor/Alg_DS/searching/3.%20%20Binary%20Search%20Tree%20-%20Height.pdf[/url]

Member Avatar for vijayan121
0
100
Member Avatar for touqra

c++98 has the convenient [ICODE]std::pair<>[/ICODE]. c++09 also has [ICODE]std::tuple<>[/ICODE]. [code=c++]#include <utility> #include <algorithm> #include <tuple> std::pair<int,int> min_n_max( const int* arr, std::size_t N ) { // invariant: N > 0 int low = arr[0] ; int high = arr[0] ; for( std::size_t i=1 ; i<N ; ++i ) { low = …

Member Avatar for vijayan121
0
104
Member Avatar for fox51

sort before inserting the string into the multimap? [code]void fill_mmap( std::multimap< std::string, int >& mmap, std::ifstream& file ) { std::string line ; for( int line_num = 1 ; std::getline( file, line ) ; ++line_num ) { std::sort( line.begin(), line.end() ) ; mmap.insert( std::make_pair( line, line_num ) ) ; } }[/code]

Member Avatar for fox51
0
165
Member Avatar for edek

> 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. [code=c++]#include <stdio.h> #include <boost/iostreams/device/file_descriptor.hpp> #include <boost/iostreams/stream.hpp> #include <fstream> #include <iostream> using namespace boost::iostreams ; struct opipestream : stream< file_descriptor_sink > { typedef stream< file_descriptor_sink …

Member Avatar for Nick Evan
0
214
Member Avatar for dark_ivader

[code]void clearCharArray( char arrayToClear[] ) { int arrayLength = 0; // Get the length of the array passed [COLOR="Red"]// this will not give you the length of the array passed [/COLOR] arrayLength = sizeof( arrayToClear ); [COLOR="Red"]// equivalent to arrayLength = sizeof( char* ) ;[/COLOR] for( int i = 0; …

Member Avatar for Lerner
0
113
Member Avatar for want_somehelp

> Are you talking about a class that only has static members and doesn't have a public constructor? >> yes that is the java style of programming. in C++, using a namespace for this purpose is canonical. [code]class foo { foo() ; public: static int f() ; static double value …

Member Avatar for vijayan121
0
465
Member Avatar for r30028

one way to extract the digits from a number is to convert the number to a string and then convert the characters in the string to digits. [code=c++]#include <sstream> #include <vector> #include <functional> template< typename NUMERIC_TYPE > std::vector<int> get_digits( const NUMERIC_TYPE& number ) { // invariant: number is non-negetive std::ostringstream …

Member Avatar for vijayan121
0
202
Member Avatar for xtheendx

another way is to use a "tag sort". ie. create an index into the vectors and then sort the indices, rather than the three vectors. note: this is usually done for efficiency reasons (swap a pair of integers instead of swap three pairs of strings). [code] // ... std::vector<std::string> lastnames; …

Member Avatar for xtheendx
0
157
Member Avatar for dan_e6

[code=c++]#include <vector> template< typename T > void magnify( std::vector< std::vector<T> >& vec, size_t BY = 2 ) { std::vector< std::vector<T> > temp(vec) ; vec.clear() ; for( size_t i=0 ; i<temp.size() ; ++i ) { std::vector<T> row ; for( size_t j=0 ; j<temp[i].size() ; ++j ) row.resize( row.size()+BY, temp[i][j] ) ; …

Member Avatar for dan_e6
0
197
Member Avatar for NoName

[url]http://www.nongnu.org/dmidecode/[/url] [url]http://ezix.org/project/wiki/HardwareLiSter[/url]

Member Avatar for vijayan121
0
46
Member Avatar for Yaka

> the way i'm trying to do is using a while loop and checking if words are more than 3 letters > long....if they are i apply changes.... > if i come accross nodes other than "alphabetical" (like a "space")within 3 nodes back the loop > breaks..do nothing..change nothing... the …

Member Avatar for Yaka
0
143
Member Avatar for Project_Panda

verify that the element is present first: [code]void student::drop_course(int d) { vector<int>::iterator f = find(c_id.begin(), c_id.end(), d); [COLOR="Red"]if( f != c_id.end() )[/COLOR] { c_id.erase(f); cout << "You have deleted course number " << d << endl; } }[/code] if there are duplicate values in the vector, you need to put …

Member Avatar for Project_Panda
0
146
Member Avatar for wiglaf

let's say you have a struct/class of this kind: [code=c++]struct A { int number ; double value ; char name[30] ; };[/code] and you want to sort an array of [ICODE]A[/ICODE]s on the member [ICODE]value[/ICODE]. first, write a comparison function that the sort can use which accepts two [ICODE]A[/ICODE]s to …

Member Avatar for vijayan121
0
398
Member Avatar for tymk

the C library [ICODE]clock()[/ICODE] does not give the wall clock: [QUOTE]the clock() function determines the amount of processor time used since the invocation of the calling process, measured in CLOCKS_PER_SECs of a second. [/QUOTE] just sleeping or waiting for input will work for [ICODE]time()[/ICODE] (which gives the wall time), not …

Member Avatar for Salem
0
5K
Member Avatar for y25zhao

> a completely literal translation into C++ would be like this yes, but we can do much better in C++. be type-safe and const-correct. [code=c++]template< typename T > class Node { private: T item; Node<T>* next; public: Node( const T& obj ) : item(obj), next(0) {} T& getItem() { return …

Member Avatar for vijayan121
0
142
Member Avatar for Jennifer84

as your 2D vector is 'rectangular' ( not 'jagged' ), you could just [code=c++]#include <vector> int main() { // 25,000 '42's in a square matrix enum { N = 5000, M = 5000, VALUE = 42 }; using std::vector ; vector< vector<int> > Numbers( N, vector<int>( M, VALUE ) ); …

Member Avatar for vijayan121
0
246
Member Avatar for amit_pansuria

download [url]http://www.openssl.org/source/openssl-0.9.8g.tar.gz[/url] unzip the tarball, read INSTALL.W32 build the library using vc++ [url]http://www.openssl.org/support/faq.html#BUILD7[/url] [url]http://www.openssl.org/support/faq.html#PROG2[/url]

Member Avatar for amit_pansuria
0
2K
Member Avatar for ktob

ideally, do not use the (now deprecated) functionality in namespace [ICODE]__gnu_cxx[/ICODE]. they have been superceded by tr1 in c++0x. use [ICODE]-std=c++0x[/ICODE] (gcc 4.3) , [ICODE]std::tr1[/ICODE] (gcc4.2) or [ICODE]boost::tr1[/ICODE] (earlier versions). the error is because [ICODE]__gnu_cxx::hash<>[/ICODE] is a struct (function object); not a function. if you have to use it, use …

Member Avatar for ktob
0
499
Member Avatar for humhaingaurav

in the original code, the layout of classes a and b are as follows (addresses increasing from the bottom of the page to the top): [code] layout of object of class A _____________________ | | | | | int a1 | | | A* -------->--------------------- layout of object of class …

Member Avatar for vijayan121
0
103
Member Avatar for PirateTUX

> I'm looking for simplicity more than anything else. I want to be able to store scripts in our > database, call them from within our C++ game engine, be able to pass arguments to them > and be able to receive data back from them. I'd also like them …

Member Avatar for hacker9801
0
111
Member Avatar for f_rele

do not pass the address of a local variable (with automatic storage duration) to a thread function; it may not be around by the time the thread executes. [code=c++]// ... char* input_sentence = new char[32]; std::strcpy( input_sentence, "ANGLE 360" ) ; thread = _beginthread( SerialThread, 8192, input_sentence ) ; // …

Member Avatar for f_rele
0
1K
Member Avatar for Nicholas_G5

> How do I match the user-entered input to item #2 in the text file the closest matching string in the text file is the one with the smallest Levenshtein distance (edit distance) from the user-entered input. [url]http://en.wikipedia.org/wiki/Levenshtein_distance[/url] > and also detect that the difference between the user-entered input and …

Member Avatar for vijayan121
0
133
Member Avatar for saswatdash83

inlining does not take place in the presence (or absence) of some compiler switches / #pragma directives. eg. presence of [ICODE]-fno-inline[/ICODE] or [ICODE]-finline-limit=small_number[/ICODE] / absence of [ICODE]-O[/ICODE] in g++ for functions that are called using pointers obtained at runtime. eg. C callbacks (the comparison function for qsort), C++ virtual functions …

Member Avatar for Ancient Dragon
0
108
Member Avatar for VernonDozier

> 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 operating system (cache manager). to achieve coherence between the two processes' view …

Member Avatar for VernonDozier
0
214
Member Avatar for vijayan121
Member Avatar for edek

> 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 [ICODE]read[/ICODE] and [ICODE]write[/ICODE] on the anonymous pipe. man read(2) [url]http://www.freebsd.org/cgi/man.cgi?query=read&apropos=0&sektion=2&manpath=FreeBSD+7.0-stable&format=html[/url] man write(2) [url]http://www.freebsd.org/cgi/man.cgi?query=write&apropos=0&sektion=2&manpath=FreeBSD+7.0-stable&format=html[/url] [code=c]#include <stdio.h> #include <unistd.h> …

Member Avatar for vijayan121
0
261
Member Avatar for CoAstroGeek

use the Boost.Python library to load the python interpretor into C++ and use Boost.Python's [ICODE]eval[/ICODE] or [ICODE]exec[/ICODE] to call the python code from within C++. [url]http://www.boost.org/doc/libs/1_35_0/libs/python/doc/tutorial/doc/html/python/embedding.html#python.using_the_interpreter[/url]

Member Avatar for vijayan121
0
182
Member Avatar for phalaris_trip

put all the common stuff in a base class and inherit from it. [code=c++]#include <iostream> template< typename E > struct enemy_manager_base { void same_for_all() { std::cout << "same for all enemies\n" ; } }; template< typename E > struct enemy_manager : enemy_manager_base<E> { void to_be_specialized() { std::cout << "generalization of …

Member Avatar for phalaris_trip
0
101

The End.