1,296 Posted Topics

Member Avatar for kux

See, for example: [url]http://www.codeproject.com/KB/cpp/exceptionhandler.aspx[/url]

Member Avatar for ArkM
0
109
Member Avatar for karang

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...

Member Avatar for mitrmkar
0
129
Member Avatar for phouse512

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...

Member Avatar for phouse512
0
247
Member Avatar for klactose

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 …

Member Avatar for klactose
0
6K
Member Avatar for Wiki_Tiki

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 = …

Member Avatar for ArkM
0
123
Member Avatar for Nemoticchigga

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...

Member Avatar for Nemoticchigga
0
287
Member Avatar for RandV80

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.

Member Avatar for RandV80
0
109
Member Avatar for jackassplus

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 …

Member Avatar for jackassplus
0
128
Member Avatar for kux

Forget NULL macros once and for all. Use pointer constant 0. Wait for nullptr reserved word in future standard releases;)..

Member Avatar for ArkM
0
749
Member Avatar for klactose

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 …

Member Avatar for ArkM
0
171
Member Avatar for CoolGamer48

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 …

Member Avatar for Duoas
0
106
Member Avatar for n.aggel

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).

Member Avatar for n.aggel
0
174
Member Avatar for faisaly

Better ask Master: [url]http://www.research.att.com/~bs/bs_faq.html#oop[/url]

Member Avatar for Narue
0
258
Member Avatar for rakeshbk402

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 …

Member Avatar for Ancient Dragon
0
188
Member Avatar for kartik14

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...

Member Avatar for ivailosp
0
70
Member Avatar for Christian2011

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 …

Member Avatar for Christian2011
0
2K
Member Avatar for Lukezzz

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 …

Member Avatar for ArkM
0
209
Member Avatar for TheBeast32

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 …

Member Avatar for aminit
0
80
Member Avatar for fedderico10

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...

Member Avatar for ArkM
0
104
Member Avatar for Emerald214

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 …

Member Avatar for ArkM
0
178
Member Avatar for asad12

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 …

Member Avatar for ArkM
0
109
Member Avatar for flecture

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 …

Member Avatar for Ancient Dragon
0
247
Member Avatar for bleh1318

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 …

Member Avatar for ArkM
0
110
Member Avatar for himsymcpp

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 …

Member Avatar for ArkM
0
2K
Member Avatar for OmniX

Use double (~16 decimal digits); 32-bit floats keep only ~5-7 decimal digits. Always use double type in math calculations!

Member Avatar for Nick Evan
0
116
Member Avatar for OffbeatPatriot

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 …

Member Avatar for ArkM
0
189
Member Avatar for gispe

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) …

Member Avatar for ArkM
0
604
Member Avatar for CoolGamer48

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 …

Member Avatar for CoolGamer48
0
1K
Member Avatar for the_virus

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...

Member Avatar for ivailosp
0
168
Member Avatar for redrum237

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;))

Member Avatar for ArkM
0
121
Member Avatar for sangham

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 …

Member Avatar for ArkM
0
7K
Member Avatar for scarypajamas

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.

Member Avatar for Narue
0
142
Member Avatar for perfectlover09

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; } …

Member Avatar for Ancient Dragon
1
228
Member Avatar for nnhamane

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]

Member Avatar for dwks
0
259
Member Avatar for nikhil.laghave

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 …

Member Avatar for ArkM
0
238
Member Avatar for mbleiche

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 …

Member Avatar for ArkM
0
1K
Member Avatar for Leena das

Write a character to stdout: int putchar(int c); from <stdio.h> or <cstdio> (in C++ only). It's enough...

Member Avatar for ArkM
0
76
Member Avatar for Code Shark

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]

Member Avatar for Prabakar
0
211
Member Avatar for jack1234

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]

Member Avatar for CoolGamer48
0
127
Member Avatar for virtual008

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 …

Member Avatar for ArkM
1
273
Member Avatar for sangham

What's a wonderful article: [url]http://www.cprogramming.com/tutorial/stl/stlmap.html[/url] Brief and clear...

Member Avatar for ArkM
0
58
Member Avatar for jack1234

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 …

Member Avatar for ArkM
0
197
Member Avatar for kadajett

Well, we see unable to work (unable to compile) code sceleton. What's your problem?

Member Avatar for iamthwee
0
102
Member Avatar for sohel08

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]

Member Avatar for titaniumdecoy
0
69
Member Avatar for VernonDozier

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...

Member Avatar for VernonDozier
0
292
Member Avatar for Q8iEnG

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...

Member Avatar for Q8iEnG
0
149

The End.