6,741 Posted Topics
Re: What version of Windows? Is it 32-bit or 64-bit? What compiler and version? There's nothing wrong with your code, and I have heard of this error on Windows 7 before. Have you tried using compatibility mode, and does it still fail? | |
Re: The operator= you define is for the Vertex class. It only applied when you assign something to a Vertex object. What you apparently want is an implicit conversion: [code] class Vertex { public: Vertex(); operator double() { return value; } private: double value; }; [/code] | |
Re: What did you do to solve your problem before running here with your tail between your legs? | |
Re: >i prefer using C cause im much familiar with C programs.. Clearly you aren't. >#include<conio.h> Please don't waste your time with this garbage. >#include<string.h> Why include a header that you're not using? >char names[10]; >int n; Global variables should be avoided. Also, names is poorly named as it defines a … | |
Re: [B]>Any thoughts?[/B] That feature already exists. If there are any approved tutorials for a forum you can find them under the "related forum features" box. As for submitting tutorials, I don't recall what the procedure is. Probably email or PM it to one of the admins for approval. | |
Re: I'm [I]not[/I] surprised that you ignored the obvious humor in said admin's response. To do so would surely cause your well reasoned suggestion to be mocked and ignored by everyone rather than nearly everyone. :icon_rolleyes: Let's also ignore that the infraction system is built into vBulletin and your complaints are … ![]() | |
Re: cin's overloaded >> operator returns a reference to the stream, which can in turn be used in a boolean context to determine the state. If you ask for a number and an invalid format is encountered, the stream enters an error state: [code] if (!(cin>> number)) { cout<<"Must enter a … | |
Re: Perhaps I'm missing something and oversimplifying, but does this not work? [code] for (int vi = 0, mi = 0; vi < numRowsVector && mi < numRowsMatrix; vi += 3, mi += 3) { for (int i = 0; i < 3; i++) { m[mi][i] = v[vi + i]; } … | |
Re: [B]>How should I change that definition to make it accept the {, , ,} directly?[/B] Use a different language that supports such an overload or wait until C++0x comes out? You certainly have options, but the array initialization list isn't one of them. Your best option presently, in my opinion, … | |
Re: [B]>can some through some light that why is it behaving like this ?[/B] It would truly suck for testing if rand weren't default seeded to a predictable value. As such, if you don't call srand, the program will behave as if you called [ICODE]srand(1)[/ICODE]. [B]>time_t t; >time(&t); >srand(t);[/B] The one-liner … | |
Re: [B]>Well at least you didn't mention premature optimization.[/B] I suspect you get that a lot. Probably for good reason. | |
Re: Yes, but not [i]only[/i] return types. Your example is fine. | |
Re: Unless a member function is declared as static, you need an object instance to call it on: [code] a.PrintStack(a); [/code] You can either make it static, or change the member function to work on [ICODE]this[/ICODE] rather than a parameter: [code] void TIntStack::PrintStack() { unsigned i = HowMany(); for (unsigned j … | |
Re: [B]>it said can't cast double* to float*[/B] Certainly not with static_cast. For that you need either reinterpret_cast or a C-style cast. Either way, it's not a very good idea to blindly jump from a larger type to a smaller type. At the very least, a preliminary test for overflow would … | |
Re: [B]>Im not asking for the code, just and idea of what to do.[/B] The requirements outline your algorithm step by step. [B]>How would i point to the first charachter in the line[/B] [code] char *front = &line[0]; [/code] [B]>and the last to the rear?[/B] [code] char *rear = &line[len - … | |
Re: C++ doesn't allow the binding of temporary objects to non-const references. Your overloaded operator+ is returning a temporary object, which you then try to pass as a non-const reference to the overloaded operator=. You can fix it by being const correct (a good idea anyway): [code] dummy& operator=(const dummy &rhs) … | |
Re: [B]>Everyone has told me to "Use Yacc/Lex" (or various variants >of them), but I really don't understand how they're useful.[/B] Then you don't know enough about how compilers work or how they're implemented. In such a case it's a bad idea to use tools because even if you end up … | |
Re: M represents the number of potential links in a node (the number of direct children). A binary tree is M=2, for example. A B+ tree stores data in the leaf nodes and only keys in internal nodes, so L in this case represents the number of data items each leaf … | |
Re: @jephthah [B]>um, search the filename string for a ".com" extension? yes?[/B] No. What kind of simpleton would do a naive extension search when the extension is largely ignored by the program loader? AV writers need to be smarter than that, because virus writers definitely are. [B]>it's pretty clear that you're … | |
Re: [B]>Can anyone tell me why such difference occurs?[/B] When printing a string (no format specifiers), the difference between puts and printf is that printf probably does more work for the same result. The reason is because printf needs to check for format specifiers while puts simply passes each character on … | |
Re: >However, this one of my attempt, please give some suggestion. The usual pattern is a loop for the rows and two loops inside of it, one for the leading spaces and one for the triangle body: [code] for i = 0 to N for j = 0 to nspace print … | |
Re: Define "help", because I get the impression you want someone to do it for you. | |
Re: It's hard to help you without knowing more about this [ICODE]String[/ICODE] class. If it's even remotely reasonable, you should be able to do this: [code] for (int i = 0; i < s.length(); i++) s[i] = toupper(s[i]); [/code] [B]>char state[2] = {patientState};[/B] This is probably wrong. I suspect patientState is … | |
Re: [B]>I'm having trouble determining why I'm getting this error.[/B] Obviously you're writing to an out of bounds index. Step through your code with a test set that reproduces the error and verify all of your indices. | |
Re: >There's a hashtable class in the STL, use that. Not according to the standard, though a hashmap is a common extension. | |
Re: [B]>Define rational number as an ADT (abstract data structure)[/B] I fail to see how this is difficult. What kept you from completing the exercise? [B]>Write a suitable C code to sort a finite set of elements >where an element may appear a large number of times[/B] Well any general sorting … | |
Re: Using the shotgun approach, I see[1]. Good luck with it, I tend to ignore people who do that because they're pretty much always looking for freebies to cheat on homework. [1] Shotgun approach: post to as many forums as possible cross your fingers. | |
Re: [B]>Nobody twisting your arm to click on the thread, is there?[/B] In theory, excessive posts could fill up the database and slow the site down enough to cost Dani more money in maintaining the status quo, and in turn she could start charging subscriptions. Every "I HAZ XXX POSTS D00D!!11" … | |
Re: [B]>If you find any grammatically mistake or you have better >way of explain the point, please do not hesitate to correct.[/B] Which amounts to rewriting your prose, I'm afraid. It's very clearly written by someone with grammar habits from another language, and those habits are hard to break with a … | |
Re: Have you tried anything, or done any research at all? You'll notice that this is a C++ help forum, not a get-your-work-done-for-you forum. | |
Re: >Can you help me. No, because you didn't even ask a question. Believe it or not, most of us probably won't have your crappy textbook on our shelves and even if someone does, the chances of them divining your homework assignment are nil. | |
Re: [B]>So can some of the knowledgeable person here tell me if it is ok, >and if so direct me to some part of the C++ standard that say so [/B] It's okay. Section 5.3.1, paragraph 2. [B]>void main(){[/B] You might also enjoy section 3.6.1, paragraph 2. The number of people … | |
Re: [B]>vectro, problem! >I am making a speel check program >Is this labary in Turbo/borland c++ difrent or what? >Uneable to open include file[/B] Good choice of problems to solve. A spell checker is clearly needed here. [B]>i have a problem with the libary #include <vector.h>[/B] <vector.h> is not a standard … | |
Re: Look at the referenced lines. Does strsong[i] give you a char, or a pointer to char? The difference is significant, seeing as how you're trying to assign to a char variable. | |
Re: [B]>expected identifier before '(' token[/B] There's not an opening paren in the line of code you posted. Are any of those enumerators macros? | |
Re: [B]>so I want to define a casting function: >double(signum s) [/B] So do it. We're not talking about rocket science here: [code] double to_double(signum s); [/code] Or are you going to complain that double(s) is so vastly superior to to_double(s) that you absolutely [i]must[/i] have a user-defined cast that uses … | |
Re: I can't claim to know Pep/8 assembly, but it looks like you're not indexing the array properly. | |
Re: FYI, mn.balakumar, you missed the boat by almost six years. You're welcome to questions, but keep in mind that for each old thread you resurrect, a recent thread goes ignored by falling to the second page. | |
Re: [B]>I rather not use conio.h for cross compatibility[/B] Good idea. [B]>is there any way to make my own "conio.h" and just include it in my compilation[/B] Um, conio.h offers functionality that's non-portable by nature. No matter how you do it, you'll end up rewriting your replacement for every target to … | |
Re: [B]>watz de meanin of malloc.h n alloc.h in c-programmin(both are different)?[/B] Both are archaic and not recommended. malloc.h is the ancient header that got merged into stdlib.h. alloc.h is typically where one might find alloca. [B]>what is the difference between 1 pointer n 2 pointer in link list of stack?[/B] … | |
Re: [B]>I can't read uint16 directly from a file using sscanf[/B] You can't read [i]anything[/i] directly from a file using sscanf. [B]>Is that possible?[/B] I think you need to be more specific. Why do you think you can't read a uint16 value? | |
Re: [B]>i have a question that i want to reverse the queue in BigO(1) time and space[/B] That's not a question. A question would be "How do I reverse a queue in O(1) time and space?". Also note that your "question" lacks sufficient detail to be answered properly. [B]>thnx in advance … | |
Re: You need to shift all elements past the one to be deleted. Currently you only shift the first, which leaves you with something not quite what you wanted. Compare with this, which deletes the first occurrence of the selected value: [code] for(int i=0; i<length; i++) { if(arr[i] == key) { … | |
Re: Unexpected garbage at the end of the string typically means you forgot to append '\0'. p.s. Start using code tags, please. I won't answer any but the most trivial questions that don't use code tags. | |
Re: [B]>I am guessing "FtoC" is a variable[/B] It's a function. [B]>I really am confused about why "to" is in there.[/B] That's part of the function name. It implies "Fahrenheit to Celsius". [B]>What does the paranthesis (float f) indicate?[/B] The function takes one argument of type float. [quote] A function is … | |
Re: [B]>Yes you can use its source code to all os[/B] Assuming a compiler exists that targets the desired operating system. That's generally a safe assumption with C, but it does mean that you'll find systems where C isn't an option due to lack of developer tools. | |
Re: >Do you think that DevC++ is a good compiler to use? Yes. >Is there a free one that is better? At your level, you wouldn't notice the differences that I would say make one compiler "better" than another. So Dev-C++ is fine unless you absolutely hate it for some reason. | |
Re: >that's kind of crappy. Yes, it is. You should take advantage of the /x modifier. :icon_rolleyes: |
The End.