1,247 Posted Topics

Member Avatar for tonyaim83

[code=c++]struct Properties { int mint; int maxt; int medt; Properties( int a, b, c ) : mint(a), maxt(b), medt(c) {} }; typedef std::map < std::string, Properties > ProcessMap; bool is_there( const ProcessMap& pmap, const std::string& pname ) { return pmap.find(pname) != pmap.end() ; } void insert( ProcessMap& pmap, const std::string& …

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

one of the great classics of c++ deals with this topic in depth; 'Large-Scale C++ Software Design' by John Lakos. [url]http://www.amazon.com/Large-Scale-Software-Design-John-Lakos/dp/0201633620[/url] 'More C++ Gems' by Stanley Lippman (F), Robert C. Martin (E) [url]http://www.amazon.com/More-Gems-SIGS-Reference-Library/dp/0521786185/ref=sid_dp_dp/002-1745891-8300801[/url] has three articles by John Lakos. these are a compact version of his seminal work. note: the …

Member Avatar for n.aggel
0
98
Member Avatar for joshua.tilson

> I think multiple threads is a bit beyond my experience... it would be easier to use a console input buffer and wait for it to be signalled. [code=c++]#include <iostream> #include <iomanip> #include <windows.h> using namespace std ; int main() { HANDLE input = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, …

Member Avatar for Duoas
0
343
Member Avatar for ganbree

> I don't want any CRT in my application do not use anything from the library that rquires CRT to be initialized. no malloc or new, no printf or streams, no statics requiring dynamic initialization or having non-trivial destructors, no atexit etc. and write your own entry-point function. here is …

Member Avatar for vijayan121
0
1K
Member Avatar for Blythe24

[code]// ... for (i=0;i<3;i++) { cout<<"Name:"; [COLOR="Red"]cin >> ws ;[/COLOR] // eat up whitespaces that may be left in the buffer // or cin.ignore cin.getline(people[i].name, 20);//<--should be ok now cout<<"HC:"; cin>>people[i].hc; // you will still have problems if the user // enters non integer values here. or if the user …

Member Avatar for Blythe24
0
149
Member Avatar for boyz

[QUOTE]The int returned by main() is a way for a program to return a value to "the system" that invokes it. On systems that doesn't provide such a facility the return value is ignored, but that doesn't make "void main()" legal C++ or legal C. [/QUOTE] - stroustrup on systems …

Member Avatar for vijayan121
0
95
Member Avatar for jbstin

what you seem to be computing is the value of 22/7 to a number of decimal digits. it is an upper limit on the value of pi [B]3 + 10/71 < π < 3 + 1/7[/B] (archemedis). for calculating the value of pi, see [url]http://en.wikipedia.org/wiki/Pi#Calculating_.CF.80[/url]

Member Avatar for vijayan121
0
226
Member Avatar for jray344

> I want to make a program with a max function taking any number of type double and returns the greatest of them for a small number of arguments (upto about seven or so), you could use overloaded function names. [code=c++]#include <iostream> #include <algorithm> template< typename T > inline const …

Member Avatar for jray344
0
266
Member Avatar for ace_joker_bt

the easiest, least error-prone and the fastest way to copy an entire stream is this: [B]output_stream << input_stream.rdbuf() ;[/B]. if you are writing a utility like this, error messages are conventionally sent to [B]cerr[/B] (not [B]cout[/B]). [code=c++]#include <iostream> #include <fstream> using namespace std ; int main( int argc, char** argv …

Member Avatar for ace_joker_bt
0
355
Member Avatar for tuxman

[code]vector < map < int , char * > > bank; bank . reserve ( 10 ); if ( bank [ 0 ] [ 0 ] == "a" ) //Memory access error[/code] this code has *two* problems. one: [B]bank[0][/B] is invalid; the vector is empty. there is no [B]bank[0][/B]. two: …

Member Avatar for vijayan121
0
97
Member Avatar for jbstin

> how can i make a new file and acces it from a class object? to make a file and access it: [code=c++]#include <iostream> #include <fstream> #include <string> using namespace std ; int main() { const char* const file_name = "/tmp/my_newfile" ; // make a new file { ofstream file(file_name) …

Member Avatar for Salem
0
97
Member Avatar for nabilchampion

here are a few utilities in bsd ports. >cat /usr/ports/textproc/rtfreader/pkg-descr RTF is the Microsoft Richtext Format, a more portable, mostly-ASCII formatting language that is exported by word processors like MS Word. These files generally have the extension .rtf, but occassionally have .doc extensions as well. This parser is from the …

Member Avatar for nabilchampion
0
1K
Member Avatar for complete

> What is best, linked lists or hash tables? depends on what your requirement is. a list is a sequence container, used to keep a collection of elements. hash tables are associative containers, used for keeping a collection of key-value pairs with support for lookup on key. > Is it …

Member Avatar for vijayan121
0
84
Member Avatar for sherwood12

> is there any way that i can add up all the values in a multiplication table? you can do this in your mind [code]1*N + 2*N + 3*N + .... + (N-1)*N + N*N == (1+2+3+...+(N-1)+N) * N == ( ( N * (N+1) ) / 2 ) * …

Member Avatar for sherwood12
0
355
Member Avatar for leetcheese

> to determine whether an array is sorted or not go through the array element by element from the beginning. if the element that you currently look at is smaller(as per the sort criterion) than the one you had just looked at before this, the array is not sorted. if …

Member Avatar for vijayan121
0
82
Member Avatar for balla4eva33

to get the command line elements, use the args passed to main: [code=c++]int main( int argc, char** argv ) { copy( argv+1, argv+argc, ostream_iterator<const char*>(cout,"\n") ) ; }[/code] to read a file line by line, use [B]::getline[/B] [code=c++]int main( int argc, char** argv ) { ifstream file(__FILE__) ; string line …

Member Avatar for vijayan121
0
428
Member Avatar for picass0

this would be less error-prone [code=c++] if(line == "abcd 2 4 6 8 10 1 3 5 7 9") { istringstream stm(line) ; string eaten ; stm >> eaten ; int number ; while( stm >> number ) myList.push_back(number); }[/code]

Member Avatar for picass0
0
96
Member Avatar for Scotty Turbo

> The error seems to happen after the program is done with EVERYTHING. for a general discussion of what this error means (buffer overrun), see [url]http://msdn2.microsoft.com/en-us/library/Aa289171(VS.71).aspx[/url]

Member Avatar for vijayan121
0
203
Member Avatar for toneeg

why don't you use this hint that your instructor has given you? it seems to be the simplest way to implement TMoney: > Hint: we would suggest storing the whole amount as an amount of cents. In this case you will > keep $1.20 as 120 and you will use …

Member Avatar for toneeg
1
347
Member Avatar for chris53825
Member Avatar for ithelp

[url]http://update.eclipse.org/downloads/drops/R-3.3-200706251500/download.php?dropFile=eclipse-SDK-3.3-solaris-gtk.zip[/url] [url]http://update.eclipse.org/downloads/drops/R-3.3-200706251500/index.php[/url]

Member Avatar for vijayan121
0
85
Member Avatar for gattispilot

i don't know anything about [B]oapiGetFocusShipAirspeedVector,[/B] but the code is incorrect unless the pointer is passed by reference [B]and[/B] the library allocates memory for VECTOR3. (this is very unlikely). [CODE]// incorrect unless the function is declared as // return_type oapiGetFocusShipAirspeedVector(VECTOR3*&) ; VECTOR3 *speedvec; // first we declare our vector oapiGetFocusShipAirspeedVector(speedvec);//then …

Member Avatar for vijayan121
0
105
Member Avatar for ChaseVoid

to compile c++ code, use g++ (not gcc). eg. [CODE]>g++ -Wall -std=c++98 -pedantic -Werror expre_Shift_Operators.cpp -o expre_Shift_Operators.exe[/CODE] > I'm still a bit confused as where to implement them nowhere, unless you encounter a situation where you absolutely cannot do without them.

Member Avatar for Duoas
0
304
Member Avatar for Ratte

[CODE]template <class T, int SIZE> class Graph { bool AddVertex(T Data) ; // ... }; template <class T, int SIZE> bool Graph<T, SIZE>::AddVertex(T Data) { // ... } [/CODE]

Member Avatar for vijayan121
0
134
Member Avatar for Lerner

on this page [url]http://msdn2.microsoft.com/en-us/express/aa975050.aspx[/url] go to the visual c++ 2005 express icon and choose the language from the 'select a language' control. if the download does not start, put the entry in the 'select a language' control back to 'select your language' and then reselect 'english' once again. this worked …

Member Avatar for Lerner
0
122
Member Avatar for freakybeavis

unfortunately, there is no portable way to discard unread characters from a stdio input stream. a language library technique would not necessarily be sufficient for this since unread characters can also accumulate in buffers other than the c++ streambuf (OS-level input buffers). to actively discard typed-ahead input (perhaps in anticipation …

Member Avatar for Duoas
0
2K
Member Avatar for tnvkrishna

> functions are defined in 5 different headers what do these look like? > a header allheaders.h which include all the header files in what order?

Member Avatar for vijayan121
0
120
Member Avatar for jaepi

converting ascii text files is trivial; you have a variety of tools. eg. tr, perl, awk, vi etc.in fact anything that can replace a cr-lf sequence with just a cr. eg. [inlinecode]awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt[/inlinecode] you could also use a utility called [B]tofrodos[/B] which is …

Member Avatar for vijayan121
0
167
Member Avatar for geekychick

ater [code] cout<<"command?"; cin>>command;[/code] you need to remove trainling whitespaces left in the buffer. modify the line to [code]getline( cin >> ws, datafind );//now this should be ok![/code] and you should be ok. note: there are other logical errors in your code, locate them after you fix this one first.

Member Avatar for geekychick
0
91
Member Avatar for helixkod

[url]http://developer.apple.com/tools/xcode/[/url] [url]http://mac.softpedia.com/progDownload/Apple-Xcode-Download-7935.html[/url]

Member Avatar for vijayan121
0
177
Member Avatar for SurviBee

you are making this way too complicated. to check if an integer is divisible by another, use the [B]%[/B] operator instead of floating points. > ..against the current vector of primes to see if any primes divide into the number evenly. you need to check only up to the square …

Member Avatar for vijayan121
0
248
Member Avatar for wjyeo

> actually did my changes by adding line[i] - 48 to it to make it back to '7'. [inlinecode]line[i] - '0'[/inlinecode] would be much better; you program would then be not dependant on a particular character encoding.

Member Avatar for wjyeo
0
299
Member Avatar for disc

if MyControl is a polymorphic type: [code]// .... try { MyControl& control = dynamic_cast<(MyControl&>( mControl ) ; control.DoSomething(); } catch( const std::bad_cast& ) { // TODO: cast failed; handle it } // ...[/code] if not: [code]// .... MyControl& control = static_cast<(MyControl&>( mControl ) ; // it is the programmer's (this …

Member Avatar for disc
0
244
Member Avatar for noobyjoe

one way to implement dragon's algorithm: [code=cplusplus]#include <iostream> #include <sstream> using namespace std ; enum { delimiter = '_' } ; int digits_beyond_delimiter( const string& str ) { istringstream stm(str) ; if( stm.ignore( str.size(), '_' ) ) { int number ; if( stm >> number ) return number ; } …

Member Avatar for noobyjoe
0
166
Member Avatar for tnvkrishna

>> can a friend method of a derived class use base class's protected members friend functions have the same access rights as the members of the class. a derived class can access (only) inherited protected members of the base class. if a derived class can access the base class's protected …

Member Avatar for vijayan121
0
113
Member Avatar for jaepi

> I should define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE to the .cpp files where I use fread and fwrite? yes, if you want to use files of sizes beyond the usual limit of 2GB on 32 bit systems. see the documentation for these macros [URL]http://www.delorie.com/gnu/docs/glibc/libc_13.html[/URL] if you are on linux, you also …

Member Avatar for jaepi
0
2K
Member Avatar for jaepi

> I was wondering why the windows compiler (specifically win32) tolerated such kind of error past tense is correct; it does not any more. microsoft c++ 6 was released prior to the the adoption of c++98; and behaved like c as far as for loops were concerned. microsoft c++ 7 …

Member Avatar for vijayan121
0
131
Member Avatar for Dee76

[code] if(truck <= v) // begin if statement { ... (dynamic_cast<Truck*>(vptr[k])) -> DOTLicense() ... } else { ... } // end if statement[/code] the dynamic_cast operator in c++ is a run-time cast operator; the corrctness of the result of the cast is guaranteed by the implementation if the cast succeeds. …

Member Avatar for vijayan121
0
653
Member Avatar for eranga262154

[url]http://msdn2.microsoft.com/en-us/library/dk77e5e7(VS.80).aspx[/url] and you should be using a std::ifstream (instead of a CFile).

Member Avatar for eranga262154
0
138
Member Avatar for mannantes

once you read a line from the file, do not copy it if it starts with "telemetre_". eg. [code]const char remove_this[] = "telemetre-" ; string line ; while( getline(infile,line) ) { if( line.compare( 0, sizeof(remove_this)-1, remove_this ) != 0 ) outfile << line << '\n' ; }[/code] to compare the …

Member Avatar for mannantes
0
4K
Member Avatar for go939

> DLLs only export functions, not classes dlls export addresses of symbols. the symbols may be of anything which has external linkage. eg. [code] int symbol_one(double) { /* ... */ } int symbol_two = 67 ; class X { int symbol_three(double) ; static int symbol_four ; }; int X::symbol_three(double) { …

Member Avatar for Duoas
0
138
Member Avatar for rugae

let us get this straight. it is usually a technical error for a class/struct to contain members which represent unencapsulated resources (unless the class/struct itself is an encapsulating wrapper for a *single* raw resource). here is a simple example: [code]struct book { book( const char* t, const char* a ) …

Member Avatar for Narue
0
127
Member Avatar for n.aggel

> How can i see the assembly produced by the compiler{if it is possible}? [B]gcc[/B]: to generate assembly pseudo code, use the -S switch. eg. [inlinecode]g++ -O2 -S -c whatever.cc[/inlinecode] to see the C code together with the assembly it was converted to: [inlinecode]g++ -c -g -O2 -Wa,-a,-ad whatever.cc > …

Member Avatar for n.aggel
0
160
Member Avatar for gehad3003

[URL]http://en.wikipedia.org/wiki/Lucas-Lehmer_test_for_Mersenne_numbers[/URL]

Member Avatar for gehad3003
0
799
Member Avatar for nicz888

> but if it is not year 2000, for example 2001. than this method wouldn't work? a normal year has 365 days, a leap year has 366. if in year[B] n[/B], jan 01 is a monday, jan 01 [B]n+1[/B] would be a tuesday if [B]n[/B] is not a leap year …

Member Avatar for vijayan121
0
95
Member Avatar for rugae

is a java programmer trying to teach c++? in c++, == always means logical equivalence. as the language is not pointer-disadvantaged, you can compare addresses (again with an ==) to check for identity. the case is different in java; you cannot comare strings for equivalence using an ==. see [URL]http://www.beginner-java-tutorial.com/java-string-comparison.html[/URL] …

Member Avatar for vijayan121
0
206
Member Avatar for skatamatic

> How do you clear the console screen without any system-compatibility issues? when the language (and the language libraries) do not provide a portable way of doing something, the usual approch is to look for a library with an api, allowing the programmer to write code in a portable way. …

Member Avatar for WaltP
0
2K
Member Avatar for rugae

if they are const integral values known at compile time, and you define them as [code]enum { const_one = 567, const_two = -34, /* ... */ };[/code] no storage would be allocated at all. if the values are not known at compile time, and you declare them as [code]extern const …

Member Avatar for vijayan121
0
130
Member Avatar for Flakester

[code=cplusplus]#include <iostream> #include <string> #include <sstream> using namespace std ; int main() { const char SEPERATOR = '-' ; string date_string ; getline( cin, date_string ) ; // dd-mm-yyyy ; istringstream stm(date_string) ; int day=0, month=0, year=0 ; char seperator1 = 0, seperator2 = 0 ; stm >> day >> …

Member Avatar for WaltP
0
122
Member Avatar for nicz888

> calculate the modulo-10 of the value using % ... the value may be negetive; you need to adjust for that. al alternative is a. convert the number to a string b. reverse the string c. convert the string back to a number. eg.[code=c++]int reverse( int number ) { bool …

Member Avatar for WaltP
0
315

The End.