2,898 Posted Topics

Member Avatar for hanvyj

the (int) cast is from C, and is not recommended in C++ for good reasons. Use the "functional" casting: [CODE] //check the video info header Width = int(&pVideoInfoHeader->bmiHeader.biWidth); Height = int(&pVideoInfoHeader->bmiHeader.biHeight); //break point here [/CODE] But in this case, long is implicitly convertable to int, so the cast is useless …

Member Avatar for Stefano Mtangoo
0
5K
Member Avatar for ithelp

There are some tools for "code refactoring", I have looked for good ones that are free or opensource, but to no avail. Visual C++ has apparently very good tools for code refactoring, but I have not used them. In this case, you want to use a serialization library like the …

Member Avatar for mike_2000_17
0
134
Member Avatar for farooqaaa

Oh... small piece of code, lots of problems: [CODE] struct Person { char* name; //this is a pointer to a char (or array of char, with null-termination) int age; //For good practice, use parameter names that don't conflict with data member names. Person(const char* aName, int aAge) //notice the "const" …

Member Avatar for farooqaaa
0
260
Member Avatar for elsiekins

Of course you can! That's the whole point of semaphores: to synchronize threads. A named semaphore is convenient because all you need to do is call sem_open with the same name and you get the same semaphore for two, three, four, or a gezillion threads. From [URL="http://linux.die.net/man/7/sem_overview"]this link[/URL]: [QUOTE]A named …

Member Avatar for elsiekins
0
290
Member Avatar for nsd11

Download and install the latest version with MinGW the file named "codeblocks-10.05mingw-setup.exe" from the links [URL="http://www.codeblocks.org/downloads/26"]here[/URL].

Member Avatar for nsd11
0
491
Member Avatar for helpme87

These are the faulty lines: [CODE] out.write("\t",4); .. out.write("\n",4); [/CODE] Where is the 4 coming from? The length of "\t" is 1. The "Wa" is probably corresponding to some memory that is stored after the literal "\t" and "\n" which both take 2 bytes (one is \t or \n and …

Member Avatar for helpme87
0
151
Member Avatar for palunix

Well, I used to work with C++Builder (the older versions, like 5 to 7) and I have always like it much better than the Visual C++ versions of the time. I don't know how much both have changed since and how they compare now. But I would say that C++Builder …

Member Avatar for palunix
0
188
Member Avatar for Kanoisa

In your InitGeo function, you call sinf(theta) several times and theta IS IN DEGREES! That's your problem. use the angle variable instead. In the future, it might be a good idea to get used to using only radians for everything, degrees are meaningless and useless most of the time. The …

Member Avatar for mike_2000_17
0
487
Member Avatar for arjunaw

As far as I know, this code is fine on a standard implementation. It seems that the underlying problem is that aCC doesn't have a "less" comparator for string types. Try implementing your own comparator for the string class and pass it as template argument in the declaration of _map2.

Member Avatar for arjunaw
0
180
Member Avatar for mrnutty

Pretty nice! But I have a few things to point out: First, gcc complains with this code because of those "typename typedef .." statements at the beginning of the MergeSort class. These don't make sense as you posted them, and I don't understand why your compiler would not complain. As …

Member Avatar for Rashakil Fol
0
881
Member Avatar for bobsta

Why do you need two operators <<? I mean if you put the code for the second one into the first one, you will only need to do "fileOut << d;". Moreover, the second call "<< d.beamlets" is not going to work because beamlets is a private member of the …

Member Avatar for dusktreader
0
211
Member Avatar for PixelExchange

I can't help much, but I can say that usually what you are referring to is called an "edit box" not a text box. That might help you in your web search.

Member Avatar for PixelExchange
0
116
Member Avatar for schaffino

I'm not going to be able to help with the details of the asm code (is there a reason why it's programmed in asm?) but I have a bit of know-how on serial ports. Did you try to implement the receiver in C++ code? From what I see (from the …

Member Avatar for mike_2000_17
0
167
Member Avatar for indigo.8

First, pArray should be declared as unsigned char* (no double stars). Allocate for pArray with new unsigned char[size]. If you are reading the characters as each being an individual number from 0 to 255 in binary format (since this is how you open the file), then forget about adding a …

Member Avatar for indigo.8
0
2K
Member Avatar for aabi

Doesn't Borland have newer products like CodeGear RAD Studio and C++ Builder 2010, now from "embarcadero" at [URL="http://www.embarcadero.com"]www.embarcadero.com[/URL]. I think those allow you to take old VCL/CLX applications and port them to the newest library versions. Of course, these have a big price tag too! Visual C++ Express and Code::Blocks …

Member Avatar for aabi
0
313
Member Avatar for pdk123

it must be a typo of some sort, because this code is fine and should compile. This will compile (I tested it): [CODE] #include <iostream> struct structA { int val; }; struct structB { double val; }; class classA { public: int function(structA * ptrA) { std::cout << "function_A called!" …

Member Avatar for pdk123
0
121
Member Avatar for mrkaran

These messages are useless, what are the "error" messages? the "in member.." just tells you where the erroneous code was called from. You should have later on some messages saying "error" and giving the file and line, e.g. "my_header.h(42)" for an error in my_header.h at line 42. Generally, you should …

Member Avatar for Rashakil Fol
0
98
Member Avatar for nbaztec

On the main() function, [URL="http://stackoverflow.com/questions/1765686/correctly-declaring-the-main-function-in-ansi-c"]see this SO-thread[/URL]. Your prof is wrong on this matter. Even the original C standards have always defined main as returning an int, although the old standards allowed to omit the return type, in which case the int type was implied. This was changed in C99 …

Member Avatar for mrnutty
0
572
Member Avatar for kirennian

I don't know of any way to do this... try [URL="http://www.cplusplus.com/reference/iostream/"]iostreams[/URL] in this case, they allow you to set precision formats as functions like setprecision(3) or whatever, this will allow a variable number.

Member Avatar for kirennian
0
285
Member Avatar for bleedi

@Garrett: >>there's no way to do it without using a pointer vector For the record, Nothing is impossible in C++: [CODE] class SuperClass { public: class Impl { public: virtual void someMethod() = 0; virtual Impl* clone() throw() = 0; virtual ~Impl() throw() { }; SuperClass Encapsulate() throw() { return …

Member Avatar for bleedi
0
439
Member Avatar for gaurav_13191

It works fine on gcc in linux. Try using [URL="http://www.codeblocks.org/downloads/26"]Code::Blocks[/URL] instead of Dev-C++, which is outdated and has several issues with Windows Vista/7.

Member Avatar for gaurav_13191
0
102
Member Avatar for Garrett2011

Tested it with g++ -std=c++0x and g++ -std=gnu++0x, in both cases: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘const int*’ for argument ‘1’ to ‘void someFunction(const int*)’ I added const because otherwise it would never work for sure.

Member Avatar for vijayan121
0
263
Member Avatar for PixelExchange

Yeah, easy. A string is a list of chars. All you have to do is: [CODE] char recvbuffer[512]; MessageBox(hWnd, recvbuffer, "Character to String"); [/CODE]

Member Avatar for PixelExchange
0
157
Member Avatar for let us c

First logic feature to see is that it is always symmetric about the central value in one sequence, so you will probably just need to store or compute one half of each row (from start to middle) and repeat in reverse for the remainder of the row (taking into account …

Member Avatar for sunyifei23
0
161
Member Avatar for sbrohee

Well from my understanding, you are sharing the objects between your different objects, i.e. the Graph and Edge objects contain pointers to shared Nodes. In this case, of course storing the objects directly is out of the question, or at least one of the two objects that hold the shared …

Member Avatar for sbrohee
0
122
Member Avatar for sbrohee

And you should probably also make the operator == constant as well: [CODE] bool operator==(const Node &) const; //.cpp bool Node::operator ==(const Node& node) const { return node.getName() == getName(); }; [/CODE]

Member Avatar for sbrohee
0
271
Member Avatar for dadam88

In this case, if the two objects are of the same class, then you can fairly easily just pass one object to a method called on the other and act on both objects in that method. In code: [CODE] class player { .. all the stuff you posted .. public: …

Member Avatar for dadam88
0
109
Member Avatar for Garrett2011

I think arkoenigs answers makes a lot of sense, and I trust that he's right. By opposition to C and C++, look at Pascal and Object Pascal (or Delphi). Delphi has nested functions because it was extended from Pascal that already had those too. It's a matter of linking strategies …

Member Avatar for arkoenig
0
533
Member Avatar for thilangane

If you want to modify the pointer primary (which was in either primary->left or primary->right in the recursive caller), you need to pass the pointer by reference. Because modifying primary in the above code snippet is not going to affect the original tree that you pass to Merge. So, simply …

Member Avatar for thilangane
0
91
Member Avatar for rObOtcOmpute

>>My class (or should I use struct?) Well classes and structs are essentially the same in C++, the only difference really is that by default all data members declared in a class are private, while the default for struct is public. So in your code, you won't be able to …

Member Avatar for Ketsuekiame
0
5K
Member Avatar for mavs123

Well first, you need types for "position,item,success" unless these are types already, but I doubt it from the names. Intuitively I can guess it should be "(int position, aDataType item, bool& success)". Then, "List" here is repetitive, I would take it out. As in: [CODE] class List { public: bool …

Member Avatar for mike_2000_17
0
116
Member Avatar for racoon8995
Member Avatar for ftl25

[QUOTE]I am using a switch statement, so they must be constant[/QUOTE] Then don't use a switch statement. The switch statement is just shorter (a bit) to write then "if () {} else if () {} ...", but it's fundamentally the same. So if it is not convenient for you, don't …

Member Avatar for mike_2000_17
0
181
Member Avatar for rax_19

For any platform, you can use [URL="http://www.boost.org/doc/libs/1_43_0/doc/html/date_time.html"]Boost Date_Time[/URL] library to do anything you want, and you can even get time in MICROSECONDS.

Member Avatar for rax_19
0
298
Member Avatar for reolynda

The output is not exactly 0.0 because floating-point values on a computer can NEVER be exact. You can [URL="http://www.cplusplus.com/reference/iostream/ostream/"]format the output[/URL] such that it doesn't display in scientific notation (like with a big negative exponent, as I assume it does now).

Member Avatar for reolynda
0
97
Member Avatar for sabareesh

First of all, the memory leak comes from this line: [CODE]m_pText = new char[nTotLen + 1];[/CODE] Because before this line, m_pText already points to allocated memory, so you need to add a delete statement before: [CODE] if(m_pText) delete[] m_pText; m_pText = new char[nTotLen + 1]; [/CODE] If you have also …

Member Avatar for sabareesh
0
139
Member Avatar for ylin333

[URL="http://www.mysql.com"]MySQL[/URL] is another simpler and free database server too. My advice is to browse your GUI library for built-in database functionality (I know Borland VCL has all sorts of nice GUI widgets for database programming, but it's a bit outdated (I haven't done database stuff for a long time), I'm …

Member Avatar for ylin333
0
235
Member Avatar for punchinello

Well basically, for rendering it (displaying it) there are two main libraries, OpenGL and Direct3D. I am familiar with OpenGL, which also has a few possibly useful utility tools like GLUT (some extra functions, and cross-platform windows), GLUI (some functions for User Interfaces), and OpenInventor (for some tools to load …

Member Avatar for punchinello
0
1K
Member Avatar for Anex

OP>>I would like to avoid using atoi function. You can use [URL="http://www.cplusplus.com/reference/iostream/stringstream/"]stringstream[/URL] for converting between strings and other types, in the same way you take input from cin and output to cout. For the rest, I think AD answered pretty well.

Member Avatar for Ancient Dragon
0
9K
Member Avatar for Kanoisa

Your problem is that a function pointer is essentially a C feature and does not support methods (that is a function acting on an object). So you can only make function pointers to static class methods or global (or namespaced) functions. >>As i think you can see i basically want …

Member Avatar for Kanoisa
0
194
Member Avatar for wyssen

This building tool is "autoconf", which is really bad compared to cmake.. but if you don't have a choice. I have worked a little with this, but not so much. The file you are looking to modify has the name "Makefile.in" in the folder where your additional source code is …

Member Avatar for wyssen
0
252
Member Avatar for Saranya Ravi

I agree with Narue, I have never heard of legitimate certifications for C/C++. In my experience, only experience rings well in employers ears. But personal experience counts too, don't be satisfied with the exercises from a course or book, take some initiative to start your own projects and get experience …

Member Avatar for mike_2000_17
0
129
Member Avatar for fire_

What you need to include is [URL="http://www.cplusplus.com/reference/clibrary/ctime/"]<ctime>[/URL].

Member Avatar for fire_
0
6K
Member Avatar for crodriguez08

I prefer spaghetti bolognese to spaghetti code... boy, isn't this a mess! I think you will have to start from the start again. This is object-oriented programming. So first of all, you need to decide what data and functionality go together. In this case, it's not a very tough software …

Member Avatar for mike_2000_17
0
387
Member Avatar for figuer25

p->next will be NULL for sure, do you see any line in addNodeAtFront() which starts with "next =".. the answer is no. So next will start with the value NULL and will remain that way. I think you have mixed up front and next in your addNodeAtFront().. not entirely, but …

Member Avatar for figuer25
0
1K
Member Avatar for joshalb

@StuXYZ.. just a little important correction, the OP should add: [CODE]virtual ~baseClass() {}; //notice the ~ for destructor[/CODE] check also [URL="http://www.daniweb.com/forums/thread300907.html"]this thread[/URL] on a very similar topic.

Member Avatar for arkoenig
0
161
Member Avatar for liompa

You can reinterpret_cast your char pointer to an int pointer or void pointer to print out its address.

Member Avatar for mike_2000_17
0
76
Member Avatar for AnkitPasi

Don't be discouraged, your code is quite good! One mistake that solves the problems with option 2 and 3: in several places, when dealing with the marks array, you do the following for example: [CODE]for(int i=0;i<5;i++,average+=marks[i]);[/CODE] Putting the "average += marks[i]" within the for-statement's third section is not good. The …

Member Avatar for AnkitPasi
0
711
Member Avatar for Fzn10

>> what is the difference between (i) *p++ & ++*p ++*p : reads as follows: pointer p is dereferenced to give the variable that it points to, then this variable is incremented and its final value is returned. *p++ : reads as follows: since postfix increment has priority over dereferencing, …

Member Avatar for sruthivin
0
101
Member Avatar for onako

Narue is right, the clear() function is not specifically guaranteed to free all the memory because for memory-optimization purposes, in general, the vector class can keep a large amount of allocated memory in anticipation of future reuse of the memory. So calling clear(), does call all destructors of the elements …

Member Avatar for mike_2000_17
0
4K

The End.