1,296 Posted Topics
Re: See, for example: [url]http://www.codeproject.com/KB/cpp/exceptionhandler.aspx[/url] | |
Re: Well, you get this code with copy/paste from Miscrosoft support site: [url]http://support.microsoft.com/kb/139652[/url] There is feedback form on this page - use it. I think, it's not so interesting work to debug Microsoft official code examples on the forum... | |
Re: In other words, you are trying to make choice between a Ford car and Ford Crown Victoria Interceptor. Truth to tell, Microsoft tuning adds 5-th wheel (NET extensions) to this wonderful model... | |
Re: Reasonable question, evasive answers... It's operator new creates new objects of Person class. It returns a pointer to a new passenger and you may add it to the vector of pointers. Be careful: the object must exist while passenger vector exists. May be, using vector<Person> (not vector<Person*>) is the best … | |
Re: See your code sceleton: [code=cpp] int method; int x; int y; ... private: System::Void btnX_Click(...) { ... int x = System::Int32::Parse(xvalue); // Oops! you have local variable x, not outer x... ... } // Bye, local (automatic) x with calculated result... ... private: System::Void btnY_Click(...) { ... int y = … | |
Re: May be this function is infected by extremely malicious stealth virus which is capable to hide not only its binary image but source code too... | |
Re: The calloc (and malloc) function never calls constructors; free() never calls destructor(s). So using new and delete operators for class objects (or array of class objects) is not only recommendation or a good style symptom - it's one of the very strict C++ language specifications. | |
Re: The 1st code fragment converts hex digit chars (0123456789ABCDEF or ...abcdef) into its binary values. For example: '0' => '\0'(0), ... '9' => '\x9'(9), 'A' => '\xA'(10) and so on. It converts all chars of the C string until end of line or end of string (zero byte) occured. It's … | |
Re: Forget NULL macros once and for all. Use pointer constant 0. Wait for nullptr reserved word in future standard releases;).. | |
Re: Some notes: 1. Use [icode]const std::string&[/icode] parameters where possible (everywhere in this class). Return [icode]const std::string&[/icode] from getLname and getFname members . 2. [icode]Car* sellCar(Car *carPtr);[/icode] - extremelly unsafe member. You made car list (vector) private (that's OK) but allow user to sell any Car from the outer world via … | |
Re: It's legal construct (better use more accurate std::string(""), avoid old C style casts). I don't like this style (tastes differ). It's an ineffective code (string constructor works on every call for default argument). It's some confusing code (pass by reference means inout parameter as ususlly). In that case I prefer … | |
Re: Some addition to dwks's post: if it were not for structure tail padding, one of the most valuable C and C++ identity [code] Type array[SIZE]; sizeof(array)/sizeof(Type) == SIZE [/code] was incorrect for some kind of Type's (as a structure from the original post). | |
Re: Better ask Master: [url]http://www.research.att.com/~bs/bs_faq.html#oop[/url] | |
Re: An application stack size - see your compiler+linker and OS manuals. For example, Visual C++ linker default is 1M, but you can specify this value: [url]http://msdn.microsoft.com/en-us/library/tdkhxaks(VS.71).aspx[/url] It's platform-dependent issue - see, for example: [url]http://www.cs.nyu.edu/exact/core/doc/stackOverflow.txt[/url] Size of compiled code - as usually, you may ask your compiler (and/or linker) to produce … | |
Re: There are tons of freeware libraries to perform ops over arbitrary precision numbers in C and C++. Search Google for "C arbitrary precision numbers library". For example: [url]http://www.tc.umn.edu/~ringx004/mapm-main.html[/url] It's not so easy to invent a new library in this area... | |
Re: The answer: yes, it's legal - but totally senseless. It's the same as: [code=cpp] int main() { 12345; return 0; } [/code] If you want, we call int "constructor" then immediatly discard created object. So internal constructor in actual fact creates local (in outer constructor body) object of the same … | |
Re: Example for vector<int> (simple and clear initialization): [code=cpp] void TestVector() { const int n2D = 4; typedef std::vector<std::vector<int> > V2D; V2D vv(1000); // Method #1: use reference variable for row[3] std::vector<int>& rv = vv[3]; for (int j = 0; j < n2D; ++j) rv.push_back(j); // Method #2: use vector as … | |
Re: I see a monstrous fragment in attached code: [code=cpp] string FileName; char __TEMP__[256]; cin.getline(__TEMP__, 256); FileName = __TEMP__; delete [] __TEMP__; [/code] Don't continue. You try to deallocate (free) stack (automatic) array. Of course, now program stack is corrupted, program behaviour is undefined and so on... Apropos, see quote from … | |
Re: It's so simple - classic forever loop;): [code=cpp] for (;;) { .... if (all_done_condition_reached) break; ... } [/code] Apropos, the second clause of for statement is a simple (and arbitrary) expression potentially coersed to bool - not only i < n... | |
Re: What's a problem? At first sight, it works... Some remarks: 1. You have Point class. Where is natural constructor [icode]Circle(const Point&,double radius)[/icode]? 2. It's doubtful style to define overloaded >> op with interactive output. Better define special member function (enterPoint, enterCircle or what else). Good stream input operator must read … | |
Re: It's entirely legal prototype in C and C++: [code=cpp] void display_draw(int mega[12][6], int draw_index); [/code] It's legal to initialize 2D array with one-level value list although better use more explicit form: [code=cpp] int val[NUMROWS][NUMCOLS] = { { /* row 0 data list */ }, ..... { /* row NUMROWS-1 data … | |
Re: Be careful: brief answers are dangerous. For example, in actual fact continue pass contol to intermediate clause of for stmt and to while condition of while and do stmts; break in switch stmt does not break any repeatable code; return stmt also yields returned value in non-void functions... IMHO, the … | |
Re: You may move originally posted class signal declaration to signal.h file as is - no need to create cpp file for the class with only inline member functions - all member functions defined in the class declarations. Now include "signal.h" - that's all. But there are suspicious parameters in the … | |
Re: Strictly speaking, Windows heap (link in the previous post) is not the same thing as CRT heap. Visual C++ includes (via <malloc.h>) special routine(s) to get heap info (see MSDN for details). Try: [code=cpp] #include <malloc.h> /// returns used heap size in bytes or negative if heap is corrupted. long … | |
Re: Use double (~16 decimal digits); 32-bit floats keep only ~5-7 decimal digits. Always use double type in math calculations! | |
Re: std::vector is an intrusive container: it contains own copies of initialization (push_backed, for example) objects (Region class objects in that case). If you don't write a proper copy constructor for Region, default copy constructor was generated and used (copy member by member). What happens with tile pointed object when Region … | |
Re: Don't include <iostream.h>. It's so called old stream header. Say him Nevermore. Use <iostream> only. You wrote [icode]#include <stdafx.h>[/icode] - Visual C++ precompiled header. Place all subsequent includes in stdafx.h wizard-generated file. No need in math.h, windows.h and stdio.h headers in your program now. You may add them (in stdafx.h) … | |
Re: From C++ Standard: A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to zero. A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type and is distinguishable from every other value of … | |
Re: See Open Watcom C++ cross-compiler (capable to create 16-bit codes in 32-bit environment). It's free now. [url]http://www.openwatcom.org/index.php/Detailed_Contents[/url] May be it helps... | |
Re: This forum (and others) is not the best place for abstract questions... Start from (for example): [url]http://en.wikipedia.org/wiki/Pseudocode[/url] or [url]http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html[/url] (first two links from my Google search;)) | |
Re: Fire point-blank: [code=cpp] #include <iostream> #include <string> #include <map> using namespace std; namespace // for example only { void DoOne() { cout << "One" << endl; } void DoTwo() { cout << "Two" << endl; } void DoNil() { cout << "Nil" << endl; } } void Mapper() { typedef … | |
Re: You can't inherit from the class with private constructors and/or destructors. So it's doubtful you catch run-time error: you can't compile С++ code based on this pseudocode. If std::vector is empty then v.back does not return consistent std::string. Please, present more adequate info about your problem. | |
Re: 1. You want an array of structures, not a structure with arrays. Declare: [code=C] typedef struct /* One student <--> one struct object */ { int id; char name[50]; /* char[5] for name length <= 4? too short */ int quiz1; int quiz2; int quiz3; int quiz4; int exam; } … | |
Re: Of course, no graphics RTL functions in C. But there are good libraries to read, convert and create bmp, jpeg and others. See, for example: [url]http://www.thefreecountry.com/sourcecode/graphics.shtml[/url] | |
Re: Strictly speaking, it's off topic message about Fortran language implementation, not about C language. It would appear you have Intel Fortran (former CVF) compiler. See this Fortran implementation reference manual (you may download it via [url]http://www-curri.u-strasbg.fr/documentation/calcul/doc/compilateurs/intel_fc_80/fcompindex.htm[/url] ), compiler directives for external procedures on C. As far as I know you … | |
Re: Better try another approach. See your problem area. You have Lines (defined here by a linear equation, but Line is not Equation only) and Points (defined by its coorinates). Well, let's declare Line and Point classes! The Point is a simple pair of doubles. Let [code=cpp] struct Point // No … | |
Re: Write a character to stdout: int putchar(int c); from <stdio.h> or <cstdio> (in C++ only). It's enough... | |
Re: Never never never use cin >> char array! [code] string word; while (cout << "Enter a word which includes NO i's : ", cin >> word, word.find('i') != string::npos ) cout << "I asked for no i's!" << endl; cout << "Thank you. Bye..." << endl; [/code] | |
Re: These typedefs and macros were created by MS team in early Windows era in the interests of portability. See brief summary and historical introduction: [url]http://en.wikibooks.org/wiki/Windows_Programming/Handles_and_Data_Types[/url] | |
Re: Some addition. As usually, you may get a drastic changes in effectiveness with setvbuf: [code=cpp] /* File i/o buffer size: the more the better (up to 64K or near) */ #define BSZ (16*1024) ... FILE *file = fopen ( argv[1], "r" ); ... /* Before any input on the file … | |
Re: What's a wonderful article: [url]http://www.cprogramming.com/tutorial/stl/stlmap.html[/url] Brief and clear... | |
Re: And don't forget to supply this class with non-trivial copy constructor and assignment operator - or (better) use std::string to keep a copy of a text literal. In the last case no need in own copy constructor and assignment op because of default member by member semantics is OK (std::string … | |
Re: Well, we see unable to work (unable to compile) code sceleton. What's your problem? ![]() | |
Re: Use double pow(double,double) function from <math.h> (<cmath> in modern C++) header. [code] double x = 2.0; double y = 2.0; double four = pow(x,y); [/code] | |
Re: Caret does not denote a pointer. It's MS .NET extention for handler of GC heap object. See, for example: [url]http://www.visualcplusdotnet.com/visualcplusdotnet14c.html[/url] Forget portability (in C++?!) with hats, gcnew and other MS VC++ tricks... | |
Re: Use a classic approach (come back to 60th;). See, for example: [url]http://everything2.com/index.pl?node_id=1293134[/url] [url]http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm[/url] [url]http://cis.stvincent.edu/html/tutorials/swd/stacks/stacks.html[/url] Of course, these three links are not ideal, but... |
The End.