1,358 Posted Topics
Re: I use VC++ 2008 Pro. It compiled, but it threw a warning about the use of wcscpy(). The error recommended the use of wcscpy_s() for security reasons. [QUOTE=VC++ 2008 Compiler]cpp22210.cpp(14) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. … | |
Re: They are roughly equivalent statements. You can do it with the standard data types too. [code] //both these statements are valid: int myInt(15); //constructor version int myInt = 15; //assignment version [/code] For the standard datatypes, there really isn't any performance penalty for doing it via the assignment version. When … | |
Re: Your prototype/declaration on line 6 does not match the definition. They must match exactly in order for the compiler to understand what you are doing. The & and * are pointer operators. If you are just learning about functions, you probably haven't learned about them yet. I'm not too sure … | |
Re: I'm not familiar with the Windows API, but this should say it all: [QUOTE] a BSTR is just a typedef of a wchar_t* [/QUOTE] It is a pointer. Pointers can be NULL. NULL is equivalent to 0, which is interpreted as false by a conditional statement. | |
Re: Apparently not. The function main() must always be specified "[B]int[/B] main()". If your tutorial doesn't show you that, [URL="http://www.cplusplus.com/doc/tutorial/"]get a new tutorial[/URL] because you're in for a long tedious ride. [edit=someone beat me to it] [QUOTE=photoyid;1142132]Try typing in: [CODE]int main() [/CODE] instead of main(). Also most people write that code … | |
Re: Good luck with that one. This is not a library archive, it's a discussion board. I'm sure you can find a library somewhere out there. | |
Re: Line 47, you are attempting to pass " [B]'[/B]red[B]'[/B] " to polygon::setc(). The single quotes cause literals to be interpreted as characters. To make the compiler interpret it as a string, you need to use double quotes. i.e. " [B]"[/B]red[B]"[/B] " | |
Re: It's not looping because you haven't written any loops. [URL="http://www.cplusplus.com/doc/tutorial/control/"]Read this.[/URL] | |
Re: The second version is better. You've reduced the ambiguity and you haven't hidden any variables. In addition, the functions are using the member variables to produce results. However..., your function2 is specified to return a double and you have no return statement. This would be a better implementation: [CODE]double function2( … | |
Re: Read your compiler's error message, it should tell you the line (within a line or 2) and what you did. You're not going to get much help here unless you share the error message. | |
Re: He's not upset, believe me. He's a mod, he's enforcing the forum rules. We can't help if you just say "I'm getting lots of errors", it's simply not possible without a starting point. You need to tell us what the errors are. Have you done a Site Search? Have you … | |
Re: [QUOTE=Robert1995;1141710]1) An overview of what your program does. My program works only for strictly pair k.[/quote] Um... This doesn't answer the question. It's asking what your program does, not when it works. [QUOTE=Robert1995;1141710]2) The result of your current code. My current code works for like 1/3 tests that i found … | |
Re: [URL="http://www.cplusplus.com/reference/string/string/c_str/"]Check out the function std::string::c_str().[/URL] Then add some commands to your while loop. | |
Re: [QUOTE=Chichiro;1140507]And now i have figured out something : there are many types of programming languages and we need them in order to create different types of software , am I right?? ( I hope I din't misunderstand it :D ) And i'm quite interested in gaming , can i do … | |
Re: You're attempting to re-declare the parameters that you have already sent to the function. The line is completely redundant and not necessary. | |
Re: Hmmm.... [URL="http://www.daniweb.com/forums/announcement8-3.html"]Read this[/URL] then try again. | |
Re: Arrays are already passed by reference by default. There is nothing you need to do to accomplish this. An array is nothing more than a pointer to the address of the first element in the array. When you access an element, you offset from the address of the first element … | |
Re: [QUOTE=programer411;1135766]Oh sorry about that I guess that I didn't think about it. About the getshape function prototype I was not told of any requirements.[/QUOTE] What exactly is your intent for getShape()? I'm guessing it is intended to select a fill character. But the net result of the function currently seems … | |
Re: [URL="http://www.sorting-algorithms.com/bubble-sort"]Bubble Sort is a very simple algorithm.[/URL] What seems to be the issue? [URL="http://www.lmgtfy.com/?q=Bubble+Sort"]What kind of research have you done?[/URL] [URL="http://www.daniweb.com/forums/announcement8-2.html"]What have you done so far?[/URL] | |
Re: [CODE]GameTable.h vector <Client*> clientInTable; Chess.cpp //Add client to table void addClient(Client *client) { clientInList.push_back(client); } //remove client from table void removeClient(Client *client) { //search client on list, when found get position pos clientList[pos] = NULL; }[/CODE] Based on what I see, you have created 2 huge memory leaks. There are … | |
Re: Is all of your code contained in one file or spread out over multiple files? Based on you mentioning "modules" in your code, and the includes you've listed. I suspect that it is spread out. Assuming that's correct, it's likely that you're not including <iostream> in one of your implementation … | |
Re: To answer your primary question, you'll need 3 files: 1.) The provided header file (a *.h file) 2.) The class implementation file (a *.cpp) file. 3.) The main application file (another *.cpp) file. The structure of the program will be the same as any other you should have done to … | |
Re: [QUOTE=mitrmkar;1138777]As per the above class declaration ... [code] // Add Matrix b to this matrix void Matrix::Add(Matrix b) { data_[ <index here> ] += [COLOR="Red"]b.[/COLOR]data_[ <same index here> ]; } [/code] [COLOR="Red"]That's [/COLOR]how you access the other object's (b) [ICODE]data_[/ICODE] member. So the next step would be to put that … | |
Re: What's the error? No one can help if they don't know what the error is or where to start... | |
Re: You might consider making your derived class completely independent of the base class. If you have sufficient control of the source, you could then redesign your derived class to add a pointer to a pre-existing instance of the base object. This would imply a private pointer variable with some sort … | |
Re: This is the way I understand it: A reference variable such as "p" becomes equivalent to, or a synonym for, "a" and you can use the variable names interchangeably without any special operations (although it's not really recommended for maintainability reasons). If you change "p" you change "a" and vice … | |
Re: When defining functions, you need to be sure that the prototype's and definition's arguments match exactly. By not making sure they match, you unintentionally overloaded num() and results() to num(long) and results(int, float, double) ... sort of..... Which confuses the compiler. | |
Re: erm..... none of us are clairvoyants... Would you like to share your code? | |
Re: Yes, but you'll have to overload the relational operators first. This is necessary so that they know how to compare elements of your class. Otherwise you will probably not get desirable results. [URL="http://www.cplusplus.com/doc/tutorial/classes2/"]http://www.cplusplus.com/doc/tutorial/classes2/[/URL] [URL="http://www.cplusplus.com/reference/algorithm/sort/"]http://www.cplusplus.com/reference/algorithm/sort/[/URL] | |
Re: You could test your program on a Virtual Machine. If it messes something, you should be able to just start up a new machine image. My IT consultant does it all the time. Don't ask me how. | |
Re: You should figure out how to use [B][noparse][code=syntax]...code tags...[/code][/noparse][/B] so that people can read your code. It's hard to tell, but it appears that your constructors are definitely not right. Also, how do you plan to get Celsius from Kelvin if you only [icode]return CelsiusTemperature;[/icode]? From what I can tell … | |
Re: [QUOTE=Aliun;1135655] Well (rand()%8)-1; is simply because [B]I was too lazy to change 8 to 7[/B] because the arrays are 0 indexed which it turns out I didn't change 8 to 7 or add a -1 to my rand's in the cpu ship chooser which fixed the problem except sometimes it … | |
Re: Do a site search. The answer is easy to find if you do. | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]Yep, looks like you're stuck.[/URL] | |
Re: A couple suggestions (hint: they're all interrelated): 1. Add a bool variable (perhaps called "quit"). 2. Convert menu() to return something other than void 3. Add a switch case 4. Figure out how to keep calling menu() as long as the user wants to Those should start you in the … | |
Re: Did you do a site search? [URL="http://www.daniweb.com/forums/thread259666.html"]Check this thread out.[/URL] | |
Re: For starters, if you ask me, this looks like a poorly thought out throw together simply for posting purposes. I think you need to pay closer attention to what you are trying to accomplish. I would advise you to sit down with a pencil and paper and do some more … | |
Re: A much better post, too bad it's not in your other thread... Anyway... You would have to use [URL="http://www.cplusplus.com/reference/clibrary/cstring/strlen/"]the strlen function[/URL] to get the string lengths. Based on what I see, you should be able to get the rest. | |
Re: You better double check your assignment. Either that or you you need to clarify your situation. What is the purpose of this program? It would wind up insanely large for the intended result... After that, [URL="http://www.daniweb.com/forums/announcement8-2.html"]read this[/URL]. | |
Re: I count 4 "civemethecodez" type thread rezzes here. Can this be closed please? | |
Re: Um.... This thread is long dead and you haven't shown any effort. You're probably not going to get much help. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Please read this[/URL], then start your own thread. | |
Re: Use code tags, there are descriptions all over the site. You've been notified before. You can not cin to a numeric literal, it has to go to a variable [URL="http://www.daniweb.com/forums/post1132136.html#post1132136"]you were told that before[/URL]. If you want help, you need to listen to what people tell you. | |
Re: The issue is with your header files themselves, not the forward declaration(s). Your classes are getting defined multiple times, they only need to be defined once. Add macro protection / guards to your headers. [URL="http://www.daniweb.com/forums/post1114822.html#post1114822"]Here are a couple examples.[/URL] You will probably have to get rid of your forward declaration … | |
Re: You only need 2 for loops, not 3. Figure out a different way to initialize and increment what you have called z. And please start using [b][noparse][code=syntax] ... code tags ... [/code][/noparse][/b] | |
Re: If you want to use a function as part of an output stream it has to return something. Neither lengthc() nor widthc() return anything. [edit] Ack!!!.. Ninja Narue!!...run!! | |
Re: [QUOTE=JHus00;1131790]It wont compile! I know something is probably wrong with my if condition but im unsure of what. [CODE]if (weight > 200) shipping_cost = 49.95; else if (weight >= 100 & < 200) shipping_cost = 39.95; else if (weight >= 50 & < 100) shipping_cost = 24.95; else if (weight … | |
Re: I can see 2 things. I'm only going to discuss the first, if you correct it properly, the second issue should disappear. Your member function Rectangle::calculateArea() really shouldn't have any arguments. It should use the information already contained within the class to determine its result, not passed in values. Passing … | |
Re: First, it's not [icode]<iostream.h>[/icode] it's just [icode]<iostream>[/icode] Second, you don't have any namespace declared. You need to somehow activate the [B]std[/B] namespace so that you can use [B]cout[/B]. I'll leave the method to you, there are at least 3 options available to you. Third: [CODE]gamma(int a,int b,float c):alpha(a*2),u(a) { beta(c,c); … | |
Re: When you define an overloaded constructor (such as a copy constructor), the compiler no longer provides a default constructor. You will have to explicitly define a PUBLIC default constructor. |
The End.