518 Posted Topics
Re: Prototype of FEDTAX is different from the function call and function defination prototype: [code=c++]double FEDTAX(double, double&, int, int&);[/code] defination: [code=c++]double FEDTAX( double GROSS, int MARITALSTATUS) [/code] perhaps you should change the prototype to [code=c++]double FEDTAX(double, int);[/code] Edit:Oops. Narue and I were editing simultaneously..... So it counts a useless post | |
Re: Best resource that answer your question : [url]http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.10[/url] In short: Just like the rest of your team | |
Re: Imagine a liked list with no data in it. You get pointer pointing to pointers.( chain of pointers) When declaring the pointers, always read from right to left [code=cplusplus] int * p; //Declare p a pointer to int int* *q;//Declare q as a pointer to, pointer to int int* * … | |
Re: Your problem is perhaps about flushing the input stream. Read the sticky thread [url]http://www.daniweb.com/forums/thread90228.html[/url] . You though, have not fully described your problem. What I feel is, you may not be able to enter the 'marks for c' as the '\n' remains in the input stream and is entered automatically … | |
Re: >can someone teach me how to use pointer in this program??i don't know if what i did in this program is correct. can you tell me how to use pointers here.thanks! Please Be specific. This is not a teaching classroom dear. You must read your text book and come to … | |
Re: There is no char as 'v0' char constitute only one character. Multi-character constants are undefined by the language. So don't use them. While converting to int, only last character is read. That means: [icode]int i=(int)'ac' ;//will store the ascii value of c[/icode] | |
Re: Well, I don't suppose you should create thread like these. BTW, I use Emacs with g++ command line on my Linux Box. I also sometime uses Gedit( the default gnome text editor) with some plug in to make compilation easy. | |
Re: Do something with arrays. Create a array and input the 5 location in it. Then run a loop and check for the given value. I mean, do SOMETHING man. We don't give free candies! | |
Re: Look, you are on the right path. If you have already overloaded the operator= and operator+, you can use them in the definition of operator+= . Say the parameter of the += operator is aSimpleString.Then, the definition of += operator may look like. [code](*this)=(*this)+aSimpleString;[/code] | |
Re: >>Hi .. I need a c++ program dealing with sales and marketing Hello, I need more than 24 hours a day to solve that!! Well, here's a TODO list: Read the Announcement and Sticky Thread :[url]http://www.daniweb.com/forums/announcement8-2.html[/url] and [url]http://www.daniweb.com/forums/thread78223.html[/url] Decide, what you want to do actually with your project. Cast your … | |
Re: First convert your equation to a closed form. The close form clearly is [tex]\sum_{n=0}^{\infty}(-1)^n\frac{x^n}{n!}[/tex] Now construct a loop and evaluate it to desired [I][B]n[/B][/I] You would need a function to calculate factorial and powers. | |
Re: Oh man!! Ancient Dragon would be snatching his hairs!! Look kavithabaskar, You are basically using recursions to avoid loops. Every series has Recursive form and a closed form(non-recursive)[Note that it is not possible for every series to have both forms]. Say, the series 1,2,3,4,5,6,7,8 has a recursive form as [TEX]A_{n}=A_{n-1}+1 … | |
Re: Takafoo, groom your basics. You don't even know how to use the modulo operator %. Now lets work upon how to guess if number is prime or not. What we gonna do is take the number and find its remainder when divided by numbers from 2 till the number-1. For … | |
Re: >I have tried that but its not working I don't believe you. Show me the corrected code after all the correction what jenas suggested. And please for heaven sake, don't use void main(). It kills and is injurious to health. [url]http://cppdb.blogspot.com/2009/02/should-i-use-void-main-or-int-main-or.html[/url] | |
Re: Make a class called[B] Point[/B]. Make two member function of type int called perhaps [B]X[/B] and [B]Y[/B]. You will have to make a two-arg constructor that will initialize the values of these data member. Write Two member functions accordingly which takes a array and its size and calculate the sum … | |
Re: 1.You are using C codes rather than C++.(The only thing in which you are using C++ is Console IO) 2.Non-Standard Headers. 3.Never use void main 4.Use fstream objects rather than fopen(). 5. [code] ch=0; ch=ch+c; ch=ch/2; c=c+ch; [/code] can be better stated as [code] ch=c; ch=ch/2; c+=ch; [/code] 6.Please specify, … | |
Re: Don't with Visual C++ MFC. Use some third-party platform independent libraries like GTK+ or wxWidgets. In that way, your code will be more portable. | |
Re: Say, you have 3 Arrays A[], B[], and C[], you want to sort all these according to A[]. What you should do is Apply the sort on A[] and while swapping the elements of A[], swap the corresponding elements of B[] and C[] along. | |
Re: Hmm, Look: I use Linux, and I have firefox in it as my [I]favorite[/I] browser. Every time I need to open a URL, I call [icode]$ firefox URL[/icode] So, if you are saying cross-platform, your problem is merely to open a file in some application. What I suggest is, you … | |
Re: Yeah, Nucleon is right. What nucleon suggested is called implicit type conversion. The compiler in this case will convert the type of [COLOR="Green"]2[/COLOR] from int to double. Hence the division performed will be on decimals(rather than integers). To do a explicit type conversion, use the static_cast<type_name>(operand) For eg: [code=cplusplus] int … | |
Re: >what i have learned is that we donot use ".h" in VC2008 like : i use "iostream" not >with ".h" Most of the C-header files like (stdio.h, string.h, math.h,) are now comes with stripped [B].h[/B] and a [B]c[/B] added before there name. stdio.h --> cstdio string.h --> cstring math.h --> … | |
Re: Array of Pointers can be used to do fast sorting. For eg. If you want to sort a unsorted array of integer. You generally can use all sorts of algorithms on the int array. But it would be less efficient as the runtime head for moving the values of int … | |
Re: I am not showing-off, But just want to tell that how can STL come to your rescue. The program submitted by Haji Akhundov, Can be shorten to few lines only. [code]#include<iostream> #include<string> #include<algorithm> int main() { std::string orig, rev; std::cin>>orig; rev=orig; std::reverse(rev.begin(), rev.end() ); if (rev==orig) std::cout<<"Yes"; else std::cout<<"No"; } … | |
Re: Just to clarify what Lerner posted, you need to have [icode]if ( digit ==[COLOR="Green"][B]'2'[/B][/COLOR])[/icode] instead of [icode]if ( digit ==[COLOR="Red"] [B]2[/B] [/COLOR])[/icode] on lines 46,49,52 etc. (I hope you know why? If not, ask us back) Also, you must add a[icode] break;[/icode] after line 21 23 25 etc. Otherwise, all … | |
Re: Well, what you want to implement is called multi-threading applications. It is OS dependent. So you may like to search a bit more about this. | |
Re: >I do not see the point of reserving memory for a string when you already know >how much space to save First of all, your goal should be clear. Here is it: You want to create a string class which will wrap the conventional char[] so that the length of … | |
Re: Yeah, why not: Yes, vectors are used in C++ They are part of the Standard Template Library. Now go and Use google.com to find out more. And further: Search for your answers before asking : Read this sticky thread :[url]http://www.daniweb.com/forums/thread78223.html[/url] | |
Re: So, you want to go back to some line without a loop? It is not suggested. Beware, do not do this practice, but for the sake of your curiosity, there exists a [B]goto[/B] statement. Please do not use this in your everyday life. There is a good example on implementing … | |
Re: So, you are a new bie in C++. You are just doing console programming right now. Right? I mean all sought of Black& white interface. You want create a window-like GUI. Hmm, Well, there are lot of GUI library out there. You can try anyone you want. But the choice … | |
Re: Don't use such a adhoc method. Use the STL method like this: [code] #include<sstream> inline std::string stringify(double x) { std::ostringstream o; if (!(o << x)) cou<<"Bad Conversion"; return o.str(); } //Heres is how to use it: string s1("123456"); int number=stringify(s1); cout<<number; [/code] For more, refer :[url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2[/url] | |
Re: Have you defined your own copy-constructor, or using the default one? (que1.IsEmpty() != true && que2.IsEmpty() != true ) is depreciated. Use ( !que1.IsEmpty() && !que2.IsEmpty() ) vmanes is rather right. you must construct a else case also. Another point to note is, you should avoid recursions as far as … | |
Re: You should perhaps read those two value in two strings variables. And then write your own add function which would find there sum. | |
Re: Look at line 34 furlong.h [icode](class Kilometer& kilo)[/icode] You are using [B]Kilometer[/B] here. Right? Now just tell me, have you told your compiler before that something called [B]Kilometer[/B] exists? No. So, what to do? Simple, you need to tell your class furlong that there exists something called Kilometer by declaring … | |
Re: Daily in the morning, chant out this line " Its better to detect error at compile time than at link time or run time." And this is the whole key to const-correctness, this is what you call it in technical terms. Read:[url]http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.1[/url] const-correctness basically ensure type safety. It should be … | |
Re: [B]I've read the thread on homework help and am not here asking for someone to do my program.[/B] I guess you didn't read about posting your code in the code tags:[url]http://www.daniweb.com/forums/misc-explaincode.html[/url] [B]I decided to use a linked list with this type declaration[/B] This is a Node of the linked list, … | |
Re: C++ FAQs by Marshal Cline is a good, free resource. If you are a absolute biginer you must read "The Correct C++ Tutorial" [url]http://home.no.net/dubjai/win32cpptut/html/[/url] Thinking in C++ by Bruce Eckel is a nice book(free online) You may visit the Sticky forum about C++ books [url]http://www.daniweb.com/forums/thread70096.html[/url] | |
Re: I am still confused why do you want to do this. I just can wonder that probably your implementation lacks a C++ compiler and hence you want to convert the C++ code to C. Well, the very first compiler(cfront), made by Bajane Stroustrup actually did this thing only. It converted … | |
Re: Read your text book!! I mean please at least TRY. skatamatic, said use a for loop. Go search what is a for loop etc. I will elaborate a little. Use a for loop to accept all number in a array. Use another for loop to check weather each of those … | |
Re: Umm, Well I just know don't why would I use the scanf() to read out a character when I have the pretty getchar() in hand. [code] char a a=getchar(); [/code] While another thing to keep in mind (this is for you, the thread starter) is that all these functions are … | |
Re: >Can you add a semicolon after MYVAR(DLLINFO, DllInfo), like Look at macro definition, the macro itself is adding a semi-colon. Adding a semicolon will actually add two semicolons. @joejoe55 Yeah, you should send the code. If is huge, just attach it, otherwise paste it here. | |
Re: What is this >>> `NodePointer nPtr = new Node(dataValue);` what is NodePointer? I didn't see it declared in any of your code! | |
Re: are you sure you have placed a #endif after the end of TemplatedFoo.h? if not, definately your code can provide you with trouble | |
Re: Please use a proper loop( a do-while should do in this case) Please use switch case instead of if( it was made for situation like this) Please do not use system() (it is unportable) And as stilskin said: if(select = 1) and if(select == 1) has a hell lot of … ![]() | |
Re: Well, your do-while loop is absolutely fine. The problem you are suffering is that: 1. You are not initializing the array new_string when you are using it. Add a [icode]for(int i=0;i<256;(new_string[i]=0),i++);[/icode] before the [icode] int x = strlen(your_string)-1;[/icode] in definition of ReverseString(). 2. You are not flushing the input stream. … | |
Re: It is not completely his fault though, I know the schools in India, they teach "Ancient" C++. But I completly agree with Narue's first comment. You have a internet connection. So go and get "Decent Book" (I told you about Thinking in C++ by Bruce Eckels). Be with the Standard … | |
Re: This is called, to kill a Mosquito with a Bazooka. Why did you went into the char thing. Look at ArkM's code, its neat, decent and much faster. And does almost the same work which you were trying to accomplish. BTW,[icode] char chr_digits[] = {'0', '1', '2', '3', '4', '5', … | |
Re: Here is a platform independent solution:[url]http://steinsoft.net/index.php?site=Programming/Code%20Snippets/Cpp/no4[/url] | |
Re: [B]The last funtion IsPrimeNumber () is giving me an error that states ..."Local Function definitions are illegal"....can someone please tell me why?[/B] This is because you didn't closed the function definition of [B]void ConvertTotalSeconds (void)[/B] (i.e. you didn't put the closing [B]}[/B] while ending the definition of [B]void ConvertTotalSeconds (void) … |
The End.