1,247 Posted Topics
Re: This has been a well known microsoft c++ (vc7/vc8) compiler bug; the compiler is picking up the wrong template specialization. It is harmless in this particular case (as well as all the other reported cases). the code is only instantiated, but not executed. (he specialization is only used in a … | |
Re: [code]class Movie{ private: string director,title,genre; public: Movie(){ director="";title="";genre="";} [COLOR="Red"]};[/COLOR] int main(){ Movie a();}[/code] | |
Re: > cant i just use visual studio from the command line ? [url]http://msdn2.microsoft.com/en-us/library/f35ctcxw(VS.80).aspx[/url] [url]http://msdn2.microsoft.com/en-us/library/dd9y37ha(VS.80).aspx[/url] | |
Re: [code=c++]Move Move::add( const Move &m ) const { return Move( x + m.x, y + m.y ) ; }[/code] | |
Re: [code=c++].... string CityName; string StreetName; GetName(CityName,StreetName); typedef vector<string> StrName; map<string,StrName>cityMap; map<string,StreetName>::iterator iterMap; cityMap[ CityName ].push_back( StreetName ) ; [/code] | |
Re: in[code]throw [B]expression[/B] ;[/code] a. the (static) type of [B]expression[/B] cannot be an incomplete type. b. the static type of the [B]expression[/B] is used to initialize a temporary object of that type (through the type's copy-constructor) into a special memory location which must stay valid during the subsequent stack unwinding. (the … | |
Re: [code=c++]struct A { A( int i ) throw(char,int,double) : value(i) {} int value ; }; struct B : A { B() throw(char,int,double) ; }; B::B() throw(char,int,double) : A(20) {}[/code] | |
Re: if your program is console based (no gui), you could use telnet. server versions of windows ship with a telnet server. all current versions of windows ship with a telnet client. see [url]http://technet2.microsoft.com/windowsserver/en/library/ddf8b035-9035-475c-ae50-1d97bde83dba1033.mspx[/url] you could also use several third party telnet server programs. eg. [url]http://www.kpym.com/en/Overview.htm[/url] putty is a very poular … | |
Re: [code=cplusplus] ostringstream stm ; stm << "Total points " << points ; MessageBox(hwnd, "You have bla bla", stm.str().c_str(), MB_OK); [/code] | |
Re: > i want the output to be added to the existing lines in the text file > i actually used a fstream and manipulated by going to end of file by using seekg to get > to the end and it actually worked.. you must be using a fairly old … | |
Re: > is there an escape sequence that lets me divide this long single line into multiple lines no escape sequence is required. a literal string can span multiple line (with quotes). [code] const char long_cstr[] = "this is the first line\n" "and this is the second line\n" "and you could … | |
Re: > Create a function template called average(). It will accept two arguments of the same type and > computes the arithmetic average, returning a double. returning a double? [B]a.[/B] what should be the average of two complex numbers? a double or a complex? [B]b.[/B] what should be the average of … | |
Re: > And my CPU occuption rate is high while at runtime as well the memory. yes, using just backtracking alone can get computationally horrendous. Warnsdorff's algorithm (goal programming) is easy to program and is very efficient. (does not work for very large boards). [quote]Backtracking algorithms (in which the knight is … | |
Re: FileSystemWatcher (in CLR) uses the win32 api functions [B]FindFirstChangeNotification [/B] and [B]FindNextChangeNotification[/B] [url]http://msdn2.microsoft.com/en-us/library/aa364417.aspx[/url] along with a wait function to get notifications of changes. to retrieve information about the changes, you coud use [B]ReadDirectoryChangesW[/B] [url]http://msdn2.microsoft.com/en-us/library/aa365465(VS.85).aspx[/url] | |
Re: > If everything is declared the same - as double - how do I make the parameters different? don't declare everything the same; create different types your code will also be more typesafe. [code=cplusplus]#include <iostream> struct temperature { double value ; inline temperature( double t ) : value(t) {} inline … | |
Re: > .. obviously not writing in binary out mode because this is just text [B]ios_base::binary[/B] only disables the control sequence translations ( for '\n', '\r' etc.) that take place during formatted input or output. to write raw binary data to a file, you will have to use unformatted output functions. … | |
Re: > The array of course instances confuses me... there is nothing to get confused about; a c-style array of course instances cannot be created at all. reason: course does not have a [B]default[/B] constructor. | |
Re: using boost.assign [URL]http://www.boost.org/libs/assign/doc/index.html[/URL] is the easiest way to fill containers; and it also works with containers other than vector<>. [code=cplusplus]#include <vector> #include <list> #include <map> #include <string> #include <boost/assign.hpp> using namespace std; using namespace boost::assign; int main() { vector<string> strings = list_of("abcd")("efg").repeat(5,"hi")("jkl") ; // "abcd" "efg" "hi" "hi" "hi" "hi" … | |
Re: > but when i copy that executable file to another computer and try to run it i get an error > that says "application failed to start because application configuration is incorrect". you also need to copy the manifest file created when linking the application. (the manifest file contains information … ![]() | |
Re: here are a few observations for starters. a. your assignment operator does not take care of self-assignment. try running [code=c++]// ... void do_assign( String& a, const String& b ) { a = b ; } int main() { String str( "hello world" ) ; do_assign( str, str ) ; }[/code] … | |
Re: this is the first result returned by a google search [url]http://oedbx.aroh.de/[/url] | |
Re: a #import directive like [B]#import "<name of the ocx file or typelibrary>" no_namespace, raw_interfaces_only \ named_guids raw_native_types <any other #import attributes>[/B] will generate a header file with the name [B]<base name of tlb/ocx>.tlh[/B]. and this header is impliciltly #included. the #import attributes specify options for generating the header file. this … | |
Re: the code in the [B]if-else[/B] is equivalent to [code] if(ARG::metrn==metrnSMD) { EventStream<complex<Lambda>> evstrTrain(fileTrain, evlsTrain); } else { EventStream<Lambda> evstrTrain(fileTrain, evlsTrain); } [/code] so the variable is not visible outside the scope of the [B]if[/B] or [B]else[/B] blocks. one commonly used work around is to have a polymorphic base class. this … | |
Re: > Error mentioned that my program requires a reinterpret_cast , a c_style cast or function_style cast.** the code you posted does not give that particular error. the two errors in your code are a. [icode]#include <iostream.h>[/icode] is not standard c++. replace this with [icode] #include <iostream>[/icode] and [icode]using namespace std;[/icode] … | |
Re: change [B]cout << os ;[/B] to [B]cout << os.str() ;[/B] [B]os.str()[/B] gets the [B]string[/B] from the stringstream. [B]cout << os ;[/B] is equivalent to [B]cout << (const void*)os ;[/B] prints the pointer value. | |
Re: for things of this kind, using a scripting language like perl would be much easier than programming it in c++. [code=cplusplus]#include <iostream> #include <fstream> #include <string> #include <vector> #include <locale> using namespace std; const string choice_letters = "abcde" ; const string answer_prefix = "ANS:" ; inline bool is_choice( const string& … | |
Re: see: More Effective C++: 35 More Ways to Improve Your Programs and Designs (Scott Meyers) ITEM 27. Requiring or Prohibiting Heap-Based Objects. and [url]http://www.aristeia.com/BookErrata/M27Comments_frames.html[/url] | |
Re: read in as a char and check if it is 'H' or 'S'; set the enum accordingly. [CODE] PayType pt ; char c ; infile >> c ; if( c == 'H' ) pt = H ; else if( c == 'S' ) pt = S ; else infile.setstate( std::ios::failbit … ![]() | |
Re: this article should contain all the information that you need: [url]http://www.ddj.com/cpp/184403638;jsessionid=S0L5ADAGUG4VKQSNDLRSKH0CJUNN2JVN?pgno=4[/url] take note of the date it was written; the references to Microsoft C++ are to the now obsolete VC++ 6.0 and not to the current 8.0 version, which has a complete rewrite of the standard c++ library (based on … | |
Re: check this library out. [url]http://code.jellycan.com/simpleini/[/url] i've not used it; but the reports that i've come across are good. and the license is non-viral (MIT) | |
Re: see [url]http://www.informit.com/articles/article.aspx?p=169524&seqNum=8&rl=1[/url] googling would get you many more such links. | |
Re: if the iterator is a [B]random_access[/B] iterator [B]one + 1[/B] is supported. if not, you could write [CODE]for( iterator_type one ; /*...*/) { iterator_type two = one ; for( ++two ; /*...*/) { /*...*/ } }[/CODE] if you want to figure out what kind of iterator it is, use [B]std::iterator_traits<>[/B]. … | |
Re: mostUsed is a const. use a const_iterator. also a prefix increment instead of a postfix (efficiency) [code]for ( map<string,int>::[COLOR="Red"]const[/COLOR]_iterator word = mostUsed.begin() ; word != mostUsed.end() ; [COLOR="Red"]++[/COLOR]word ) { /*...*/[/code] | |
Re: you must assign static ip addresses to the two machines from one of these three non-routing address pools [B] 192.168.0.0[/B] to [B]192.168.255.255[/B] [B]172.16.0.0[/B] to [B]172.31.255.255[/B] [B]10.0.0.0[/B] to [B]10.255.255.255[/B] see [url]http://www.faqs.org/rfcs/rfc1918.html[/url] once you have done that, use any file transfer mechanism that catches your fancy; FTP, sockets programming, NFS or whatever … | |
Re: see [url]http://msdn2.microsoft.com/en-us/library/aa489518.aspx[/url] and [url]http://msdn2.microsoft.com/en-us/library/ms801998.aspx[/url] | |
Re: [code=c++]#include <sstream> #include <string> #include <iostream> template< typename T > inline std::string to_string( const T& v ) { std::ostringstream stm ; return (stm << v) ? stm.str() : "error" ; } int main() { double value = 1.2345 ; std::string str_value = to_string(value) ; // c++0x // std::string str_value = … | |
Re: use [B]std::sort[/B] with a predicate. [url]http://www.codeguru.com/forum/showthread.php?t=366064[/url] [url]http://www.codeproject.com/vcpp/stl/functor.asp?df=100&forumid=2645&exp=0&select=1791095[/url] | |
Re: > getting managed code to talk to unmanaged code? the easy way is to just mix the managed and unmanaged code as required. this is called IJW ( "it just works" ). using p-invoke is only slightly harder. [code=c++]#include "stdafx.h" #include <iostream> #include <algorithm> #include <iterator> using namespace System; using … | |
Re: > you should have posted this in the C forum. There is nothing specific to C++ in this thread. do you really mean [CODE]namespace { int foobar( int i ) { return ++i ; } }[/CODE] is c++, but if you place the same function in the global namespace, it … | |
Re: > This should have never compiled in gcc ... true, it should never compile without errors in any c++ compiler. but g++ does accept it without specific switches that turn on C++ compliance. eg. [B]> g++ --std=c++98 --pedantic -c whatever.cc [/B] or [B]> g++ --ansi --pedantic -c whatever.cc [/B] would … | |
Re: you could use a std::set< std::string > ( or a map or a hashmap as you suggested ) to check for the duplicates. see this thread: [url]http://www.daniweb.com/forums/thread81348.html[/url] | |
Re: something like this perhaps? [code=c++]#include <iostream> inline int larger( int a, int b ) { return a>b ? a : b ; } inline int smaller( int a, int b ) { return a<b ? a : b ; } int main() { int number ; std::cin >> number ; … | |
Re: [CODE]// istream file, string str1, str2, str3 // read to the first colon assert( geline( file, str1, ':' ) ) ; // get first letter after the first colon assert( geline( file, str2, ':' ) && !str2.empty() ) ; char c = str2[0] ; // read all the letters after … | |
Re: [code]for (k = 0; k < MAXNUMS; k++) // Display and calculate the voltage { cout << "The voltage is " << volts[k] << endl; volts[k] = current[i] * resistance[j]; }[/code] not 'Display and calculate the voltage' but 'calculate first and then display the voltage' swap the two lines in … | |
Re: [B]DefineDosDevice[/B] (with DDD_RAW_TARGET_PATH flag) could be used to create a junction in the object namespace; the junction can then be used as a dos path string. [url]http://msdn2.microsoft.com/en-us/library/aa363904.aspx[/url] if the device already has a dos name, [B]QueryDosDevice[/B] can be used to get information about dos device names. [url]http://msdn2.microsoft.com/en-us/library/aa365461.aspx[/url] | |
Re: you still use RegQueryValueEx. [CODE]LONG WINAPI RegQueryValueEx( HKEY hKey, LPCTSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, // will be set to the type of data // (eg. REG_BINARY if value was binary) LPBYTE lpData, LPDWORD lpcbData );[/CODE] see [url]http://msdn2.microsoft.com/en-us/library/ms724884.aspx[/url] for the registry value types. | |
Re: the pointer returned by [B]string::c_str()[/B] is a. a [B]const char*[/B]. if you need a[B] LPSTR[/B] ([B]char*[/B]), you need to copy ([B]strcpy[/B]) it to an array of chars b. usable as a [B]LPCSTR[/B] ([B]const char*[/B]) only as long as you have not modified the string. you need to make your own … | |
Re: > but how would u carry out this operation??? a= 10 + b; // it's not (b+10) >> the problem you are facing can be eliminated by using friend functions. [B]friend[/B] functions are functions which are not members of the class, but are granted the same access rights as members … | |
Re: if you do not mind the viral license, you could use this. [url]http://www.matteolucarelli.net/libreria/GetPrivateProfile/GetPrivateProfile.c.htm[/url] after sanitizing it by removing things like calls to [B]atoi[/B]. | |
Re: there are many simple tutorials available on the net. like this one [url]http://www.huihoo.org/ace_tao/ACE-5.2+TAO-1.2/ACE_wrappers/docs/tutorials/online-tutorials.html[/url] |
The End.