1,247 Posted Topics

Member Avatar for gopi kannan

[quote=jbennet;411781]yeah turbo c++ is ancient, nonstandard and unstable[/quote] completely incorrect. the current version of turbo c++ (the free version is now called 'Turbo C++ Explorer') does support standard ANSI C and ISO/IEC C++ languages and libaries. it includes the Dinkumware C++ runtime libraries and supports the Boost library. download from …

Member Avatar for WaltP
0
217
Member Avatar for SirJames

[code=cplusplus] #include <iostream> #include <cctype> #include <cstring> #include <algorithm> using namespace std ; const char* const ranks = "A23456789TJQK ATJQK" ; struct on_rank { bool operator() ( char a, char b ) const { return strchr(ranks,a) < strchr(ranks,b) ; } }; int main() { enum { NCARDS = 5 }; …

Member Avatar for vijayan121
0
105
Member Avatar for kogorman

[quote=Ancient Dragon;410687]...you might check the boost libraries to see if it contains anything usefule.[/quote] yes, boost.iostreams could be used. [code=cplusplus] #include <iostream> #include <boost/iostreams/stream.hpp> #include <boost/iostreams/device/file_descriptor.hpp> #include <fcntl.h> // posix open #include <cassert> #include <iterator> #include <stdlib.h> // system using namespace std ; using namespace boost::iostreams ; int main() { …

Member Avatar for vijayan121
0
218
Member Avatar for shouvik.d

the total store of c++ functions is fixed. these are the functions which were written when the code was compiled; there is simply no way to create new functions at run time. what differentiates function objects from functions is that they are objects (variables). in principle we can do everything …

Member Avatar for vijayan121
0
310
Member Avatar for mauro21pl

[code]**&p == *(*&p) == *p *&*&*&x == *&*&x == *&x == x[/code] unary & is the addressof operator; unary * is the dereference operator. so [CODE]&x[/CODE] == address of x (pointer to x) [CODE]*&x [/CODE]is dereference of the pointer to x ie. dereference address of x (== x itself).

Member Avatar for Bench
0
108
Member Avatar for shouvik.d

it is a standard component of the library in c++0x see [url]http://www.open-std.org/jtc1/sc22/wg21/[/url] libstdc++ (gcc 4.30) and dinkumware std c++ library implement this natively; boost.tr1 library could be used if you have an older compiler and boost. [code=cplusplus] #include <iostream> #include <functional> int main( int argc, char** argv ) { //using …

Member Avatar for Rashakil Fol
0
153
Member Avatar for biganimal
Member Avatar for Akilah712

[code=cplusplus] #include <fstream> #include <string> #include <vector> #include <cassert> using namespace std ; int main() { const char DELIM = '>' ; const char* const file_name = "whatever" ; ifstream file( file_name ) ; assert(file) ; vector<string> names, sequences ; string line ; // skip lines till we get one …

Member Avatar for Akilah712
0
282
Member Avatar for VISHOWNTAR

now that you have solved it, can you make it more efficient? ie. find the max for each row and each col by making one single pass through the elements of the array.

Member Avatar for VISHOWNTAR
0
2K
Member Avatar for ejptccs123

1. [B]g++ -DHAVE_CONFIG -Wall -std=c++98 -o myprogram[/B] 2. [B],/myprogram hello world[/B] in 1., the command line args are used by the c preprocessor, some are forwarded to the compiler and linker in 2., the command line args are passed to myprogram and are available as parameters passed to main

Member Avatar for thekashyap
0
171
Member Avatar for Hamrick

[code=cplusplus] template <typename T> void template_function( T arg ) ; template <typename T> void function( void (*func)(T) ) { /* ... */ } // this is better, would also accept compatible functions // and function objects template <typename FN> void better_function( FN arg ) { /* ... */ } [/code]

Member Avatar for vijayan121
0
331
Member Avatar for adotl

[quote=joeprogrammer;372921]...NetBeans...That's for Java. An entirely different programming language.[/quote] see [U][url]http://www.netbeans.org/products/cplusplus/[/url][/U] it is lighter on resources than eclipse+cdt, and would be a good option for a c++ IDE, particularly on a unix/linux platform.

Member Avatar for jbennet
0
141
Member Avatar for Hamrick

it is fine if your idea is just test out your understanding of templates, functors and inheritance. however, functors (aka function objects) are usually not implemented as object oriented types for a variety of reasons. [code=cplusplus] template <typename T> struct sort_base { virtual void operator()( T array[], const int size …

Member Avatar for thekashyap
0
150
Member Avatar for alembic21

[code=cplusplus] ifstream file("a:\\crypnums.txt"); vector<int> numbers ; int i ; while( file >> i ) numbers.push_back(i) ; assert( file.eof() ) ; [/code] or [code=cplusplus] ifstream file("a:\\crypnums.txt"); vector<int> numbers ; istream_iterator<int> begin(file), end ; copy( begin, end, back_inserter(numbers) ) ; assert( file.eof() ) ; [/code] both assume that the integers are seperated …

Member Avatar for vijayan121
0
123
Member Avatar for Hamrick

a. it is probably wiser not to hold the seperator string (_sep) as a pointer; this might get us into trouble if a temporary was passed as the second constructor arg b. the hard coded assumption that CHAR_BITS==8 should be done away with c. we could reuse the functionality available …

Member Avatar for Hamrick
1
208
Member Avatar for sowmi

[quote=sowmi;395444]...I have 100 commands and whenever the commands are pressed the corresponding function + arguements...[/quote] it is much more flexible to represent functions as objects . this would allow free functions, function objects and member functions to be treated polymorphically. also, since these are objects, they can support operations (eg.bind). …

Member Avatar for vijayan121
0
156
Member Avatar for Hamrick

> the assembly output doesn't show me the code generated for C++'s strlen(), just my strlen() and xstrlen(). the microsoft C++ compiler recognizes and directly inserts optimized inline code for several functions (including strlen). functions like strlen in the Standard C library are available in both intrinsic and non-intrinsic forms. …

Member Avatar for Hamrick
0
294
Member Avatar for vladdy19

if the enums have consecutive integral values (as in this case), we can increment by adding one to the value. [code=cplusplus] #include <iostream> int main() { enum level { FRESHMAN=0, SOPHMORE=1, JUNIOR=2, SENIOR=3 } ; const char* const literal_level[] = { "FRESHMAN", "SOPHMORE", "JUNIOR", "SENIOR" } ; for( level lev …

Member Avatar for Ancient Dragon
0
160
Member Avatar for jan1024188

the server will bind to an address and start listening on it. the client socket is usually dynamically bound and tries to connect to the socket at the address the server has bound. so the port the client tries to connect to should be the same as the one the …

Member Avatar for jan1024188
0
153
Member Avatar for jan1024188
Member Avatar for aasi007onfire

C++ annotations (groningen) is one of the books you could check out. available online at [url]http://www.icce.rug.nl/documents/cplusplus/[/url]

Member Avatar for vijayan121
0
166
Member Avatar for zandiago
Re: date

[code=cplusplus] const char* const months = "*ABCDEFGHIJKL" ; inline char month_to_code( int m ) { assert( m>0 && m<13 ) ; return months[ m ] ; } inline int code_to_month( char c ) { const char* p = strchr( months, toupper(c) ) ; assert( p!=0 && p!=months ) ; return …

Member Avatar for zandiago
0
118
Member Avatar for kinggarden

if you are not alowed to reorder the original sequence, but are allowed to use auxiliary storage [code=cplusplus] #include <vector> #include <set> #include <iostream> #include <string> using namespace std; template< typename CNTR > void print_duplicates( const CNTR& cntr ) { set< typename CNTR::value_type > unique ; for( size_t i=0 ; …

Member Avatar for vijayan121
0
735
Member Avatar for Thinka

[quote=Nichito;358676]nonetheless, i found out that clock() works different depending on which compiler you are working... 4 example... in dev c++, i measured clock measured 1/1000... but turbo c++ measured 1/20... the thing is... i don't know why...[/quote] [code=c] clock_t start, end; double cpu_time_used; start = clock(); /* whatever */ end …

Member Avatar for Narue
0
1K
Member Avatar for JRM

[code=cplusplus] #include <vector> #include <algorithm> using namespace std ; int main() { vector<int> cntr( 20U, 7 ) ; int* array = new int [ cntr.size() ] ; typedef vector<int>::iterator iterator ; int x = 0 ; for( iterator it = cntr.begin() ; it != cntr.end() ; ++it, ++x ) { …

Member Avatar for Narue
0
235
Member Avatar for bala24

a constructor which [B]a.[/B] can be called with one arg[B] b.[/B] is not marked explicit is also an implicit conversion operator. [code=cplusplus] struct A{}; struct C {}; struct B { B(const A&) {} explicit B(const C& ) {} }; A a ; C c ; B b = a ; …

Member Avatar for thekashyap
0
117
Member Avatar for bala24

except in a trivial situation, where the compiler can optimize away the storage, a reference is stored in memory as an address. so for, [inlinecode]struct A { double& ref ; A(double&d) : ref(d) {} };[/inlinecode] sizeof(A) == sizeof(double*) when a reference is passed to a function, what is passed is …

Member Avatar for bala24
0
125
Member Avatar for hbweb500

[code=cplusplus] #include <vector> #include <boost/tokenizer.hpp> #include <string> #include <vector> #include <iostream> using namespace std; using namespace boost; int main() { string str = "The boost tokenizer library provides a flexible " "and easy to use way to break of a string or other " "character sequence into a series of …

Member Avatar for hbweb500
0
254
Member Avatar for bala24

members or base class sub-objects cannot be initialized inside the body of the constructor; they can only be assigned to. initialization is always before the body of the constructor executes. if not initialized expliciltly using colon initialization, the implementation will provide default initialization if available. for any member which does …

Member Avatar for ~s.o.s~
0
116
Member Avatar for tcyge

you must be using a microsoft compiler (or a compiler with abi compatibility with the microsoft compiler). if the destructor is virtual, an entry needs to be made for the destructor in the vtbl of the class. for [inlinecode]delete ptr_abc[/inlinecode], two things need to happen. a. the correct destructor must …

Member Avatar for vijayan121
0
77
Member Avatar for Matt Tacular

a sequence container can also be initialized with a sequence identified by a pair of iterators. [code=cplusplus] char cstr[] = "abcdefghijkl" ; std::list<int> list2( cstr, cstr+sizeof(cstr) ) ; [/code] in c++0x, the following would be another way: [code=cplusplus] std::list<int> list5 = { 23, 6, 57, 575, 7575, 75 }; // …

Member Avatar for iamthwee
0
259
Member Avatar for sadaka

line 4: LRESULT CALLBACK WindowProcedure (HWND hwnd, [COLOR=red]UINT 5 message[/COLOR], WPARAM wParam, LPARAM lParam); line 9: _pAE = new AppEngine(HINSTANCE, LPSTR, LPSTR, WORD, [COLOR=red]10 WORD[/COLOR], int, int); these are the errors. the compiler/ide you are using seems to emit very poor error messages.

Member Avatar for sadaka
0
166
Member Avatar for bops

for controls other than buttons, you could handle the WM_CTLCOLORXXX notification; eg. WM_CTLCOLOREDIT for an edit control. for buttons, the button needs to be an owner-drawn button; for such a button the system sends the parent window a WM_DRAWITEM message. see: [URL]http://msdn2.microsoft.com/en-us/library/ms673346.aspx[/URL]

Member Avatar for vijayan121
0
220
Member Avatar for ongxizhe

[quote=~s.o.s~;371983]... I still vote for Python or Java.[/quote] glad to note that you dropped perl from the list. a 'write once, read never' language is probably not good for anyone. smalltalk would rank very high among good languages for beginners; it is arguably the best language for beginners.

Member Avatar for ongxizhe
0
380
Member Avatar for jaepi

see [url]http://www.cprogramming.com/tutorial/initialization-lists-c++.html[/url]

Member Avatar for jaepi
0
304
Member Avatar for Matt Tacular

[code=cplusplus] if( std::find( alist.begin(), alist.end(), x ) != alist.end() ) { /* do this */ }[/code]

Member Avatar for Matt Tacular
0
99
Member Avatar for Daan

the file you are trying to compile it is a C (not C++) file. compile that with gcc, not g++. in your C++ code include the header as follows: [code=cplusplus]extern "C" { #include "whatever.h" }[/code]

Member Avatar for vijayan121
0
143
Member Avatar for sundar divas

[quote=Salem;381245]It's just simple maths [code] void process ( int a, int b ) { char var[10]; process( 0, 0 ); } [/code] You have a char array, so that's 10 bytes. Two integers - say 4 bytes each (total 8). Each call has a fixed overhead of several bytes (say …

Member Avatar for vijayan121
0
105
Member Avatar for castegna

a. correct your existing code so that it will compile without errors; test it. b. convert the recursive algorithm to a tail-recursive form. c. convert the tail-recursive implementation to an iterative one. for steps b. and c., see: [url]http://en.wikipedia.org/wiki/Tail_recursion[/url] [url]http://www.nist.gov/dads/HTML/tailrecursn.html[/url]

Member Avatar for Narue
0
127
Member Avatar for complete

[quote=thekashyap;381268]...modify a const by casting[/quote] really you should not. a constant whose value is known at compile time a. may (would) be placed into memory with read-only access by the compiler if it has a static storage class. b. the compiler can (should) treat such a contant as if it …

Member Avatar for vijayan121
0
121
Member Avatar for machine

[code=cplusplus] class D { // ... D operator- ( const D& d2 ) const; // ... }; D D::operator- ( const D& d2 ) const { // ... [/code] would also make your code const-correct.

Member Avatar for machine
0
250
Member Avatar for ITech

[URL]http://www.freeprogrammingresources.com/cppbooks.html[/URL] [URL]http://www.thefreecountry.com/documentation/onlinecpp.shtml[/URL] [URL]http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-13.html[/URL] Thinking in C++ vols 1 & 2 (2nd ed) by bruce eckel is probably the best online book for beginners. [B] [/B]

Member Avatar for vijayan121
0
187
Member Avatar for CRD

for standard C++ (ISO/IEC 1998,2003), the project type you would use is one of [B]Win32 Console Application[/B] / [B]Win32 library[/B] [B]/ General MakeFile Project[/B]. if you are new to Visual Studio 2005, start with a [B]Win32 Console Application[/B] project. and in the project settings, disable microsoft language extensions. ( either …

Member Avatar for CRD
0
147
Member Avatar for quintoncoert

the issuse is that your program is written in C++/CLI, the dll is in pure C++. to use the dll, you would need to use p-invoke. you could [code=cplusplus] #pragma unmanaged #include <dll header files> #pragma managed [/code] you would also need to make modifications in your project settings (eg. …

Member Avatar for vijayan121
0
254
Member Avatar for katerinaaa

you could use the boost tokenizer library. here are a few links: [URL]http://www.boost.org/libs/tokenizer/index.html[/URL] [URL]http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/tokenizer/examples.cpp[/URL] you could also use the boost string algorithms library (if the file is read line by line into a string) [URL]http://www.boost.org/doc/html/string_algo.html[/URL]

Member Avatar for katerinaaa
0
184
Member Avatar for parthiban

9/5 is an integer expression (==1). use float fahrenheit = celsius * float(9)/5 + 32 ; it would be better to use doubles instead of floats unless there is an externally imposed constraint. salem, didn't see your post!

Member Avatar for parthiban
0
127
Member Avatar for quintoncoert

[code=cplusplus] #include <boost/lexical_cast.hpp> int main( int argc, char* argv[] ) { if( argc> 2 ) { try { int value = boost::lexical_cast<int>( argv[2] ) ; // use value } catch( const boost::bad_lexical_cast& ) { // cast error } } [/code] this is part of the proposal for c++0x (in TR2) …

Member Avatar for vijayan121
0
148
Member Avatar for fahima.s

here are two links that may be helpful: [URL]http://www.codeproject.com/cs/media/Motion_Detection.asp[/URL] [URL]http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome[/URL]

Member Avatar for vijayan121
0
93
Member Avatar for venomlash

windows: see [URL]http://msdn2.microsoft.com/en-us/library/aa394587.aspx[/URL] apple: see [URL]http://developer.apple.com/technotes/tn/tn1103.html#TNTAG3[/URL] bsd: use dmidecode (in ports).

Member Avatar for vijayan121
0
61
Member Avatar for jaepi

[url]http://users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-thread.html[/url] [url]http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html[/url] [url]http://www.codeproject.com/useritems/MultithreadingTutorial.asp[/url] you would fing several more if you google on: threading C tutorial

Member Avatar for jaepi
0
126

The End.