2,898 Posted Topics

Member Avatar for priyanka.js28

You need to make the destructor in the base class as virtual (otherwise the base class destructor will be called directly). Try this code: [CODE] #include <iostream> class base1 { public: virtual ~base1() { //notice virtual keyword here std::cout << "base1 destructor called!" << std::endl; }; }; class derived1 : …

Member Avatar for arkoenig
0
264
Member Avatar for anuj_sharma

The problem is that calling "cin >> ch;" will wait for the enter to be pressed, then will read the first char. This will leave the newline or '\n' character on the input stream, so the next time you do gets() to read the line, it will grab the '\n' …

Member Avatar for anuj_sharma
0
100
Member Avatar for ssmg

Well, I agree with jonsca, use a while loop. You can also use "continue" to come back to the start of the while loop from anywhere inside the loop. If it really is not going to work with a while loop, do everything you can think of to make it …

Member Avatar for ssmg
1
12K
Member Avatar for Bruynz

Well, I think tesuji answered pretty well, but if I may add something to answer your original question: >>should I use some RDBMS or should I just write some stucts or better yet classes that relate to each other through some methods and then write them to a binary file? …

Member Avatar for Bruynz
0
229
Member Avatar for saintboy

Line 17, 24, 33 are all the same and they are all wrong for one very important reason. "post_evaluation *t;" declares a pointer to a post_evaluation object, but it is not initialized. So "t" points nowhere or anywhere, which is really the same thing. You cannot use t if it …

Member Avatar for mike_2000_17
0
153
Member Avatar for hasrule

Your problem is with handlerthread. Are you sure that once a thread is started that it remains valid when going back to idle or when it is initially at idle? This seems to mean that the handlerthread pointer is destroyed, or its internal handle to the actual OS thread (pthread …

Member Avatar for mike_2000_17
0
693
Member Avatar for vavazoom

Well "master mike" is back to quote tesuji... Your program crashes because of this portion of the code (line 40 to 52): [CODE] //For each i > j: row i - (Cij/Cjj)* row j i = j++; for(int row_i = i; row_i < N; row_i++) { for(int row_j = j; …

Member Avatar for mike_2000_17
0
216
Member Avatar for bleedi

@AkashL: The auto_ptr will help because it will make sure the "paramTime" in this case is deleted before main() exits, but it is not ideal because, as you said, it is not reference counted, so if the pointer is copied to other functions and stuff, it will get deleted at …

Member Avatar for bleedi
0
186
Member Avatar for CanYouHandstand

Well, in the expression "const QMimeData* const", the first const means that the QMimeData is not changeable (constant) and the second const means that the pointer to it is not going to change either. If you don't need to change the pointer (i.e. create your own QMimeData object), then make …

Member Avatar for Agni
0
202
Member Avatar for mebob

Well.. the error is very strange.. never seen that before. But the source of it is very easy to find: Your first two functions have a ";" before the opening braces! Two weird errors, two misplaced semi-colons. Also, where is the implementation for your constructor? And, you should not use …

Member Avatar for mebob
0
272
Member Avatar for vidyasmani

Wow! that's something creepy... trying this, it helps me understand why this is how it is: [CODE] int main(){ { int j=5; std::cout << ((++j) + (++j)) + (j++) << std::endl; } { int j=5; std::cout << ((++j) + (++j)) << std::endl; } { int j=5; int x = ++j; …

Member Avatar for arkoenig
0
106
Member Avatar for pato wlmc

Which is better for development? IDEs: I have to say windows just because either Borland or Microsoft IDEs are really full-featured, but also expensive. If money is an issue, then Linux has great tools too, KDevelop is now a pretty descent rival to Visual Studio or RAD Studio. General Programming …

Member Avatar for Excizted
0
181
Member Avatar for elsiekins

Don't let this blow your mind: [CODE] aReturnType some_function_name(aParameterType some_parameter, aReferencedType& some_ref_parameter) { aType some_variable(SOME_INITIAL_VALUE); for(anIterator some_iterator = some_start_value;some_iterator != some_end_value; ++some_iterator) some_variable += some_other_function_name(some_parameter, some_ref_parameter); return yet_another_function(some_variable); }; [/CODE] These are just phony names people use in text books to make examples (so is Foo and Bar, before you …

Member Avatar for mrnutty
0
98
Member Avatar for nu2cpp

>>error C2582: 'operator =' function is unavailable in 'Cord' This means there is no default assignment operator for type Cord, you need to implement one. This error would not happen in C++. RANT ALERT! This is C++/CLI, not C++. So you will probably find better luck looking for answers by …

Member Avatar for mike_2000_17
0
223
Member Avatar for wesduncan

time.h does not support milliseconds, it is a C legacy library made for systems that "in general" cannot support more than seconds precision. Of course, modern computers do support milliseconds, and most often microseconds too. If your code is C, I believe there is no way. If in C++, there …

Member Avatar for wesduncan
0
797
Member Avatar for abhijeet kamble

[QUOTE]is it compulsary to write main fun in c and c++,can we only write 1 main fun.[/QUOTE] Well the main function is the entry point for the executable. Just a special function that the compiler knows should be the sort-of first implicit call to start the program. So if you …

Member Avatar for mike_2000_17
0
119
Member Avatar for 2008macedonkon3

[QUOTE]At no time has floats ever been faster than doubles. [/QUOTE] Well... that's absolutely true, if you restrict the discussion to the CPU. But floats have always been very popular for efficiency reasons in game programming because GPUs are (or at least "were", in my days) designed with custom floats …

Member Avatar for Kanoisa
1
2K
Member Avatar for tehb

Many bigger projects use building (compilation) tools such as cmake which select compilers based on the source file extensions, and .c would be passed to the C compiler. Some projects often use .c files (C code) as third-party sources for some special purposes such as hardware drivers and other IOs, …

Member Avatar for tehb
0
276
Member Avatar for hg_fs2002

You should copy the data pointed to by d inside the Add function, because of this, from [url]www.cplusplus.com[/url] on string.c_str(): [QUOTE]The returned array points to an internal location with the required storage space for this sequence of characters plus its terminating null-character, but the values in this array should not …

Member Avatar for mike_2000_17
0
100
Member Avatar for saransh60

Well in "char* str="my name";" the _string_ "my name" is a list (or array) of characters (char) and "str" is a pointer to the first character in the list. So by incrementing the pointer "str" you get a pointer to the next character, then the next, and the next again, …

Member Avatar for Fbody
0
135
Member Avatar for xcarbonx

1. For C++, I would disagree with case 1 above, in this case you want to use a reference as in: [CODE] #include <iostream> //notice no .h here void change(int a) { a+=1; } void changeref(int& a) { //notice & instead of * a+=1; //notice no leading * } int …

Member Avatar for mike_2000_17
0
102
Member Avatar for Kanoisa

It seems quite alright to me! One tip: [CODE] //THIS: cin>>userIn;//get user input int loopLimit = atoi(userIn.c_str());//get the numberEntered //COULD BE JUST THIS: int loopLimit; cin>>loopLimit;//get user input [/CODE]

Member Avatar for arkoenig
1
183
Member Avatar for PixelExchange

Are you trying to write a SpyBot? I'm not going to be the one to help you with that... are you also trying to read the credit card numbers that people might be writing on other open windows, while they are "playing your game"... just joking! To be fair, I …

Member Avatar for PixelExchange
0
109
Member Avatar for yan_yan

Simplest program, the famous Hello World program: [CODE] #include <iostream> int main() { std::cout << "Hello World!" << std::endl; return 0; }; [/CODE]

Member Avatar for mike_2000_17
0
76
Member Avatar for Luther von Wulf

There is one naming convention that is used a bit and it's called Hungarian notation. I'm not sure of the exact format, but essentially it uses leading letters to indicates certain things, more or less like this: [CODE] class IAbstractClass { //notice "I" for abstract or interface or base classes. …

Member Avatar for mike_2000_17
0
184
Member Avatar for computerdummy30

Well I don't know what you imagine "x^y" to be supposed to do, but I can tell you what it does and why the compiler warns you about it. The ^ operator in C++ is a bitwise XOR operator, so x^y produces the results of x XOR y (XOR is …

Member Avatar for Fbody
0
111
Member Avatar for tkmandanna

First off, I can't help on the AT side, but I know matlab pretty well. There are essentially two possibilities: either run in matlab and use DLLs to interface to C++ code to deal with AT commands and whatever else, or compile matlab using RTLab. So if you are in …

Member Avatar for mike_2000_17
0
148
Member Avatar for Scu

Why do you need AddElement? the list already has functions to add (push_back), delete, insert, etc. All you need to take care of with the clsMyClass is make sure that all constructors work (and do not throw exceptions) and that you have proper copy-semantics, i.e., you need to implement a …

Member Avatar for Scu
0
115
Member Avatar for Luther von Wulf

Try to write a serialization library like [URL="http://www.boost.org/doc/libs/1_43_0/libs/serialization/doc/index.html"]this one[/URL]. That should keep you busy for a while, and help you learn advanced OOP concepts of C++ that may challenge you a bit. Also see [URL="http://www.boost.org/doc/libs/1_43_0/libs/spirit/doc/html/index.html"]these tutorials[/URL], they will show many nice ways of mixing template meta-programming and generic programming, that …

Member Avatar for mrnutty
-1
2K
Member Avatar for tennis

Yes and no. This will create a different static variable in each .c you compile. To solve this, declare it as "extern" as well, this will tell the compiler to look for all other declarations of the same variable and "merge" them into a single one. Of course, if having …

Member Avatar for mike_2000_17
0
196
Member Avatar for Jacobah

In MFC or any other GUI library, things are Event Driven which mean that the execution of the program is not your typical main_while_loop type of thing you find in procedural programming. Your application is simply reacting to events (handling) as they come, so your question is a bit bizarre, …

Member Avatar for Jacobah
0
190
Member Avatar for empror9

I know how to fix your code, but to let you do it on your own, I will say this: the recursive formula (the second one) is used to compute each _term_ of the first equation one after the other. In your implementation, you use "result" in the recursive formula, …

Member Avatar for mike_2000_17
0
5K
Member Avatar for johnnyturbo3

Well for small projects it ok to put everything in the header files, but as the project grows it will become more and more inconvenient. Since you have read stuff on C++ I will not repeat to much that the "philosophy" behind headers and cpps is to declare classes and …

Member Avatar for mike_2000_17
0
7K
Member Avatar for Dimesh

Look up SDL (cross-platform API like the Win32 API) or Qt (like MFC or other GUI libraries).

Member Avatar for mike_2000_17
0
67
Member Avatar for Nulled

C++ is the most flexible and universal language for programming. [URL="http://www2.research.att.com/~bs/applications.html"]Look at the list firstPerson posted[/URL]. It goes to show that virtually all games are in C++, virtually all serious scientific coding is in C++, all Microsoft apps too, virtually all kernel libraries of operating systems, etc. etc. One of …

Member Avatar for Yojimbo_Beta
0
230
Member Avatar for renar

To match your very little effort at asking the question.. my answer is: std::sort (<algorithm> header).

Member Avatar for Ancient Dragon
0
261
Member Avatar for nwhitfield

Well it looks like a good book, and gamedev is a good source for openGL game programming. Consider first going through the [URL="http://nehe.gamedev.net"]NeHe Tutorials[/URL], that's a great start for openGL rendering (but the advanced tutorials are a bit outdated, in the sense that better techniques exist today). About the book …

Member Avatar for mike_2000_17
0
99
Member Avatar for mikenable

First off, the line "TicTacToe game(char X,char E);" actually is interpreted by the compiler as a function declaration, so that is what the error message points. "game" is declared as function, as far as the compiler can tell. In any case, this is not valid syntax, as Dave pointed out. …

Member Avatar for mike_2000_17
0
294
Member Avatar for alex-VX

These errors say that the compiler cannot find the definition (implementation) of the class CPlayer. You must have forgotten to add the Player.cpp file to the compilation process (or its .o file, or the static library to which it was compiled).

Member Avatar for mike_2000_17
0
274
Member Avatar for yasirjani

>>treasure on each space line could be 3,2 or 1 but not 0. I don't understand that, but for the rest.. You can call rand() as many time as you want, so that solves the problem of having multiple treasures. Also, to avoid walls and borders and other treasures, just …

Member Avatar for yasirjani
0
108
Member Avatar for aukeebler

Please post with code tags! This line in displayTotal: [CODE]for (int x = 0; x < 12; x =+ 1)[/CODE] Should be this:[CODE]for (int x = 0; x < 12; x += 1)[/CODE] Notice the += instead of =+ (this would mean "x = +1").

Member Avatar for PatrixCR
0
65
Member Avatar for computerdummy30

[QUOTE] Total of food: $2.87 Tax: $0.19 Total for order: $3.06 [/QUOTE] Man that's a cheap meal! What country do you live in where you can get a soda, burger and fries for 3 bucks at only 6% sales tax! Anyhow.. I think your code is fine and its almost …

Member Avatar for EngSara
0
89
Member Avatar for so0lid

As it is now, the original string gets replaced by the sub-string, so you do get the sub-string back from the function. But if you want it like you said. First you need to allocate new memory for the sub-string, with the right size (n2 + 1). Then you write …

Member Avatar for mrnutty
0
98
Member Avatar for RStartin

Well this is one problem with: [CODE] priority_queue<Job,vector<Job*>,less<vector<Job*>::value_type> > event_list; [/CODE] In this case, vector<Job*>::value_type is essentially equal to Job* (not exactly, but no need to worry about the difference). Then, now less<Job*>, really means that the elements will be sorted by the comparison "a < b" where a and …

Member Avatar for RStartin
0
386
Member Avatar for epicasian

That's nasty.. I hate VC++! I think you must be missing some headers, or at least VC++ doesn't find them.. these things are hard to find by yourself, especially since VC++ is probably the compiler with the least useful error messages (no back-tracing!). What I do in these cases, I …

Member Avatar for mike_2000_17
0
165
Member Avatar for aukeebler

This means that the compiler cannot find the definition of the function calcCelsius that matches the prototype: [CODE] void calcCelsius(double); // the "_cdecl" thing is just the default calling convention. [/CODE] So either you didn't provide a definition for that function, or your definition doesn't match the prototype exactly, or …

Member Avatar for aukeebler
0
78
Member Avatar for old_jefrey

As suggested by firstPerson, class or function templates are typically the best way to achieve common functionality for different types. So you can look up templates for info on that. Also, operator or function overloading can make the code more uniform (as in the above, your functions don't need to …

Member Avatar for mike_2000_17
0
141
Member Avatar for epicasian

It looks a bit to me, from your class names, that defining your own namespaces might be a good option for you to consider instead of nested classes.. just a suggestion.

Member Avatar for epicasian
0
109
Member Avatar for aukeebler

Your prototype and your definition should always match EXACTLY, that is true for functions and everything else. Since the point of the prototype is to tell the rest of the code exactly how the function, that is defined later, should be called, so it is meaningless if the definition does …

Member Avatar for WolfPack
0
199
Member Avatar for mennaya

Well first, you say (wrist, elbow, shoulder, etc.) so I guess what you have to start with is not the actual position and orientation of each part of the body, but the position of each joint of the body. Since parts are between joints, you need to transform those joint …

Member Avatar for 0x69
0
343

The End.