518 Posted Topics

Member Avatar for Dia.A

In some books I read: Elevator Simulation:: The program will simulate elevators. The user pushes a button ( by pressing a number key on the keyboard. Number indicates the floor on which he is) and then the elevator decides its path so that it could fill up requests of most …

Member Avatar for tux4life
0
300
Member Avatar for billsmith7

>>I believe this is how I would input the data but i'm not totally sure on that either... Run the damn code and tell us if it worked fine or gave error. If error, what error?

Member Avatar for billsmith7
0
130
Member Avatar for Lukezzz

[URL="http://www.innosetup.com/isinfo.php"]Inno Setup[/URL] is a free installer for Windows programs. I used it my several projects wherein I needed to port my Linux Application to Windows user ( windows user really like this setup.exe) You will be amazed by its simplicity and power.

Member Avatar for Lukezzz
0
167
Member Avatar for Lukezzz

You perhaps should enable the "View Hidden files" option from the folder option of the windows explorer.

Member Avatar for Lukezzz
0
303
Member Avatar for ganmo

Try this: [code=cpp] class Bike { public: Bike (const int, const string, string, double); private: const int w; const string b; string c; double ws; }; Bike::Bike(const int wheel, const string brand, string color, double wheelsize): w(wheel), b(brand), c(color), ws(wheelsize) {}[/code] It is generally better to write constructor using member …

Member Avatar for ganmo
0
174
Member Avatar for quadmani

[COLOR="Green"]&p[2][/COLOR] is same as [COLOR="Green"]&(*(p+2))[/COLOR] which is same as [COLOR="Green"]p+2[/COLOR] So cout<<p+2 will print the array which has the the first element as the 3rd element of p. Hence the output is "ndon" p[11] means *(p+11) that means "tell me the value of the 11th location from p" (remember p …

Member Avatar for tux4life
0
289
Member Avatar for JainishP

You could create a array called [B]count[/B] and store the number of occurrence of each of the element of test[] in that. Then simply find the largest element of count[]. Suppose then the largest element of count[] is the k-th element, then the mode will be test[k].

Member Avatar for ArkM
0
4K
Member Avatar for BehzadSh

>>in php we can append string, how could I do this in C++: You could if you were using strings in C++. But the very fact is that you are not using strings but c-strings here. [code=cpp] #include<iostream> #include<string> int main() { std::string arr="Foo Bar"; std::cout<<arr; //prints Foo Bar arr+="X"; …

Member Avatar for BehzadSh
0
294
Member Avatar for catagon

There are several option when you write functions that return multiple values: 1. Using references: You could have few parameters that will be passed as references and use them to store the output [code=cpp] void split_decimal(double input, int& integer_part, double& fraction_part) { integer_part=static_cast<int>(input);//convert input to integer // and store in …

Member Avatar for siddhant3s
0
85
Member Avatar for Duki

Boost's Asio is a good one if you want it platform independent: [url]http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio.html[/url] I have seen more of platform specific libraries which could suit you. There is an excelent Beej's Tutorial on Sockets with C, but it works with C++ too. You will need to code like a C programmer …

Member Avatar for Duki
0
114
Member Avatar for philtron

What is the error message? [code=cpp] chg = RATE606; else if loc = (zip.find("605", 0)); (loc >= 0); [/code] else if requires a condition. The proper code would have been [code=cpp]void calcShippingCharge(string zip, int RATE605, int RATE606, int &chg) { //search zip code for proper prefix if (zip.find("606", 0) != …

Member Avatar for philtron
0
105
Member Avatar for goldstmarc

You could also do something like this [code=cpp] for (int i =0,curr_pic=3; i < 52; i++) { Card[i].Num = i%13;// Num will only get value from 0-12 Card[i].Pic = curr_pic; if( i%13==0) //after every 13 cards increment the value of cur_pic cur_pic++; } [/code]

Member Avatar for siddhant3s
0
121
Member Avatar for siddhant3s

Hey, I saw some textual reputation here on Dani for short period some minutes ago. "siddhant3s is a jewel in roghsiddhant3s is a jewel in roghsiddhant3s is a jewel in rogh" Yeah, it was repeated many times. Then I checked that some text reputation was assigned to everyone!! Whats that. …

Member Avatar for Dani
0
58
Member Avatar for valtikz
Member Avatar for kbmmartin

>>Why didn't the C++ standard also have the delete operator reset ptr to NULL? First of all you are simply **NO ONE** to ask question like this. C++ standards have been made by the most proficient and experienced programmers of this language. If you think there should be a feature …

Member Avatar for siddhant3s
0
6K
Member Avatar for preet4fun

Read: [url]http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.2[/url] And then look at Narue post

Member Avatar for siddhant3s
0
146
Member Avatar for Peyton

Just make the parameter of function of type istream and pass by reference. Maybe an example would help: [code=cpp] int print_the_istream(std::istream& the_stream) { if (! the_stream) return 0;// error, return false std::string buff; while (!the_stream.eof()) { the_stream>>buff; std::cout<<buff; } return 1;// return true.Everything is fine } //usage: int main () …

Member Avatar for ArkM
0
10K
Member Avatar for nature_love

He perhaps, meant that he wants to customize the uranary * operator ( the dereferencing operator) for is custom class. I don't know why would you like to do that but here is what I got: Overload dereference operator like this: [code=cpp]T& operator*() const //this will return some value of …

Member Avatar for ArkM
0
269
Member Avatar for catagon

void main is a crime. Always use int main. [url]http://cppdb.blogspot.com/2009/02/should-i-use-void-main-or-int-main-or.html[/url] if( day=0) will always be true. Use if(day == 0) instead. There is a difference between = and ==. The former is an assignment operator. The later is a logical operator, it evaluates whether the LHS and RHS are equal …

Member Avatar for catagon
0
166
Member Avatar for preet4fun

Checked your program, it is running just fine. You are asked to show that the exception handler which takes the Base class(runtime_error) as its argument can handle exception where the derived class(DevideByZeroExeption) is thrown. This is perhaps what your instructor wants from you: [code=cpp] try { result = quotient( number1, …

Member Avatar for siddhant3s
0
147
Member Avatar for sailorsun

You have to first create a data structure. An array or vector of int should be the most correct data structure. Then ask the user how may value you need to input. Run a loop and accept all those value in a vector ( or array,) from the user. ( …

Member Avatar for siddhant3s
0
118
Member Avatar for ejiroy

This is from [url]http://www.cplusplus.com/reference/string/string/data/[/url] about string::data: Get string data Returns a pointer to an array of characters with the same content as the string. Notice that no terminating null character is appended (see member c_str for such a functionality). So modify your code something like this: [code=cpp]cout << "Enter the …

Member Avatar for siddhant3s
0
186
Member Avatar for itsraghu

You have to prefix std:: before ofstream, as in [code]std::ofstream myfile;[/code] >>f:\sp\vctools\icrt_bld\self_x86\crt\src\open.c Is this your source file? This is a .C file. Make it .CPP This may fix your problem. Some implementation (particularly on windows) wants your source file of C++ to end with .cpp

Member Avatar for itsraghu
0
1K
Member Avatar for paolomontero

You don't have to do this. It will be a very nice thing if your compiler will point out the error for you. In this case it will. Just tell the user of your class that you can only templatize those classes which have the CompareTo function. This way, if …

Member Avatar for paolomontero
0
191
Member Avatar for mimis

Gtk+ can be a real pain on Windows. I got it to work after several attempts. There is a GTK+ installer for windows available on the website. The main problem arises, when you need to compile your GTK+ code. My team used Code::Block IDE on windows. But we were not …

Member Avatar for siddhant3s
0
98
Member Avatar for kvprajapati

>>There are several free compilers, such as Code::Blocks, Dev-C++, and VC++ 2008 Express. ( Note to OP: I am talking to Ancient Dragon, this has got nothing to do with you) I never knew Code::Blocks and Dev-C++ are compilers!! I thought they were IDEs ;) Or am I sensing it …

Member Avatar for John A
0
167
Member Avatar for IrvineKinneas50

A general swap algorithm is : [code]//say you want to swap var1 and var2 temp= var1; var1=var2; var2=temp; [/code] In c++ you can use the ready made function [URL="http://www.cplusplus.com/reference/algorithm/swap/"]std::swap()[/URL] defined in <algorithm> header file which can do this job for you. [code=cpp] // swaps the content of m-th element of …

Member Avatar for siddhant3s
0
92
Member Avatar for super.mina

>>Edited the code, try again, Sorry, OP is right. x[100]={1,2,3,0,3,5,4,1}; will print 2 elements To the OP: You cannot !. Yes you cannot. However surprise it may bring to you, the truth is you really you cannot. Thats why most of functions dealing with int array often asks you to …

Member Avatar for tux4life
0
8K
Member Avatar for Ani2084

>>char* userData = "\0"; Seeing this? This tels the compiler to allocate 2bytes to userData, So if your user enter text more than one character, you're doomed. Better change to this: [code=cpp]const int MAX=20; char userData[MAX];[/code] I am smelling that you are using an old compiler. If not, why not …

Member Avatar for siddhant3s
0
69
Member Avatar for Gewalop

>>I think you should send the argument "word" as a reference and not copies of the argument. He is passing a pointer actually. >>the encryption function is working fine, but I'm having troubles with the decryption. Even Encryption is not good. Here is the output: [code]siddhant3s@Xion:~/Documents$ ./testofcallbyreference Enter the word …

Member Avatar for siddhant3s
0
154
Member Avatar for nirav bhatt

RAND_MAX is a constant defined by your implementation ( i.e. it is defined by what compiler are you using on what platform) is a large number but it is at least 32767(it may be greater depending on your implementation) rand() function generates a random integer between 0 and RAND_MAX For …

Member Avatar for ArkM
0
91
Member Avatar for Clockowl

To generalize: :: stands for scope resolution operator( I know you know this) which has two operand : the scope[1] and the object/function. When you don't write the scope explicitly ( like ::gcd() ) it means you are referring to the global scope. [1] Scope can be a Class or …

Member Avatar for Clockowl
0
178
Member Avatar for vddmanikanta

>>initialize static member function >>initializing a function These two things doesn't mean anything in C++. You don't initialize a function. You initialize an object ( or a variable, whatever you call them). Things you can do with functions are: Declare them Define them Call them Overload them Templatize them May …

Member Avatar for vddmanikanta
0
127
Member Avatar for booker

>>I initialize the matrix as following and when then I cout, the program crashes.. Look at the [B]<endl[/B] it should be [B]<<endl[/B] Are i and j defined? Try running this code on your compiler; [code=cpp]int matrix[512][512]; for(int i=0;i<512;i++){ for(int j=0;j<512;j++){ matrix[i][j]=-1; } } cout<<matrix[100][100]<<endl;[/code]

Member Avatar for booker
0
190
Member Avatar for Beginerman

I have not seen your code thoroghly but the immediate thing I would like to point out it this: [icode]if (a = months+12){[/icode] as you may see you have used a = rather than ==. In c++( and even in C) = will always evaluate true. To test for a …

Member Avatar for Beginerman
0
145
Member Avatar for spring sun

To the OP: As it has been said: Programming is an Art. Some have god gifted talent in programming. Others develop their talent by practicing more problems. It is simply not possible for us to solve this problem (of having non-logic mind in programming.)

Member Avatar for cause&effect
0
129
Member Avatar for cassie_sanford

Your solution is posted as the announcement of DaniWeb :[URL="http://www.daniweb.com/forums/announcement8-2.html"] We only give homework help to those who show effort[/URL] This is what it reads: [QUOTE=Administrator of DaniWeb]This forum is meant for discussing programming languages in addition to exchanging code and algorithms. However, it has become a problem where too …

Member Avatar for siddhant3s
0
497
Member Avatar for Argo54325

[QUOTE=Argo]so the problem is, I don't know how to fill it with data. I've seen that you could use myMap.insert<pair<some stuff... but i dont know how or if you can use that on maps of maps. [/QUOTE] I don't know why you created maps of maps. maps of [URL="http://www.cplusplus.com/reference/std/utility/pair/"]pair[/URL] would …

Member Avatar for Argo54325
0
213
Member Avatar for crh0872
Member Avatar for ellimist14

>>do I have to define the structure globally? No just declare it globaly. Like this [code=cpp]struct ROPES; int fillStruct (ifstream& fin, ROPES ropes[], int n); int main() { struct ROPES { members }; return0; } int fillStructs (ifstream& fin, ROPES ropes[], int n) {} [/code]

Member Avatar for ArkM
0
110
Member Avatar for lancevo3

Read the prototype of [URL="http://www.cplusplus.com/reference/iostream/istream/getline/"]getline[/URL] The first argument should be a char array ( a cstring). Tell us what is the structure of student.

Member Avatar for lancevo3
0
108
Member Avatar for deedub

You are not using the peek properly: The code should be like this [code=cpp]int main() { int num1, num2; char chr; cout<<"Enter an integer to start: "; while (cin.peek()!='|') { cin>>num1>>num2; cout<<num1<<' '<<num2; //do things with num1 or num2 } cout<<"Bye!\n"; }[/code]

Member Avatar for tux4life
0
2K
Member Avatar for Psykocyber

>>[icode]cout << (dynamic_cast <Person*>(p))->getAverage();[/icode] Look what are you doing. You are casting a Person pointer with Person only. What is the effect? change it to [icode]cout << (dynamic_cast <Student*>(p))->getAverage();[/icode]

Member Avatar for Psykocyber
0
129
Member Avatar for JerryShaw

Read: [url]http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/[/url] >>Can someone tell me what happens to checkSum with this sprintf method checkSum is a c-string( array of chars) its value is set by Total's hex value converted to c-string. In short, after this command, Total will be converted into its hex and in form of a string …

Member Avatar for JerryShaw
0
270
Member Avatar for RizzLinux1388

>>// With the "(" and ")" added i guess it should copy value like pointers do Even if you didn't it would still be same. To the OP: The "Test" of you professor is perhaps not good. The interface given by him is already implemented as [URL="http://www.cplusplus.com/reference/string/string/swap/"]std::swap[/URL] What sky diploma …

Member Avatar for jephthah
0
204
Member Avatar for aerobama

This is what I always say: Use the standard library for the standard jobs. If I assume you are familiar with std::vectors, std::maps, std::sort, there is no reason not to use them. 1.Create a std::map of <string,double> 2.Transverse the file and store the GPA of the particular name in the …

Member Avatar for siddhant3s
0
211
Member Avatar for Nickair

>>Start learning C, then you can go into the object oriented parts of C++ Bad advice. Will turn into the "I-write-c++-code-but-am-actually-a-C-programmer". If you want to learn C++. Learn C++. Don't learn C. Rather it can perhaps spoil your C++. C++ and C are two different languages. Read the following thread:[url]http://www.daniweb.com/forums/post818590.html#post818590[/url] …

Member Avatar for tux4life
0
104
Member Avatar for Clockowl

> Making p a shadow of an int p sneaks the error past the compiler in your example. // typename // Compiles with logic error if commented out` > end quote. If you uncomment the typename, you are intentionally telling compiler that `T::Baz` is a type which is, off course …

Member Avatar for siddhant3s
0
2K
Member Avatar for Stefano Mtangoo

[QUOTE=Clockowl]>>I really enjoy GTK+/gtkmm. Lots of demos and documentation. [/QUOTE] True. I too use GTK+ as for the same reason that it has loads of documentation. But warn you, GTK+ don't go so 'native' on windows. Anyways, If I got to choose form wxWidget or QT I will choose wxWidget …

Member Avatar for NicAx64
0
440
Member Avatar for bkeenom

Considering that you have already have defined LinkedList::getPoly(int n) Your operator[] should look like this. [code=cpp]Polynomial& Database::operator[] (int n) { return getPoly(n); }[/code]

Member Avatar for bkeenom
0
130

The End.