565 Posted Topics

Member Avatar for kbondarchuk

Here's a little example: public class A { public static void main(String a[]){ print("Hello World."); } public static void print(String str){ System.out.println(str); } } You'll have to include your main function, and your own function into a class. In Java everything has to be an Object/class, not like in C++ …

Member Avatar for JamesCherrill
0
213
Member Avatar for dlgmu537

Here's what my compiler says: > Implicit super constructor Student() is undefined. Must explicitly invoke another constructor In your class Student you have just one construcor, and it's a custom constructor with two arguments. In order to call that super constructor, it seems that you need to have explicitly in …

Member Avatar for dlgmu537
0
196
Member Avatar for subtoneweb

Well guys, it's been four months sine the initial OP post. I don't know if he's looking into this program anymore. **KaeLL** I know that you're new on our website, but a read through our rules wouldn't have hurt you. Perhaps getting rid of unnecessary variables and declarations would clear …

Member Avatar for deceptikon
0
410
Member Avatar for mjbor1

Perhaps this function will suite you better in checking if a string is a palindrome. bool pal(string str){ Stack<char> s, s2; //we'll use 2 stacks for (size_t i=0;i<str.size();i++) s.push(str[i]); //put all the characters into the stack for (int i=0;i<(int)str.size()/2;i++) s2.push(s.pop()); //pop as many elements as string's length/2 and push them …

Member Avatar for Lucaci Andrew
0
271
Member Avatar for <M/>

Try browsing using Atomic Browser, or Dolphin on iPad. I currently use them on my iPhone, and the editing ribbon appears.

Member Avatar for diafol
0
102
Member Avatar for ucvx32

Well, you can have multiple single classes, and than to have an instance of some classes in another classes. Here's a quick example: #include <iostream> using namespace std; class A{ public: A(){} char* addA(){return "addA\n";} }; class B{ public: A a; //public instance of class A in class B; B(){} …

Member Avatar for ucvx32
0
134
Member Avatar for Cosmo_Kramer

You could check their time library: [Click Here](http://docs.python.org/2/library/time.html)

Member Avatar for Lucaci Andrew
0
82
Member Avatar for TheMrPatrick

use the pre-built methods: int a=5; String b = Integer.toString(a); //b="5" String b=5; int a=Integer.parseInt(b); //a=5

Member Avatar for TheMrPatrick
0
304
Member Avatar for Cosmo_Kramer

You know, Google provides good results... [Click Here](http://code.activestate.com/recipes/365640-thread-safe-multiqueue/)

Member Avatar for Cosmo_Kramer
0
217
Member Avatar for Cosmo_Kramer

print "The data file specifies a "+ z+ "-server simulation." I'm not sure if it'll work, I currently don't have an active python ide/compiler.

Member Avatar for Cosmo_Kramer
0
191
Member Avatar for Umairuddinahmed

Here's a quick example of how you can integrate command line arguments into your program: #include <iostream> #include <cstdlib> int main(int argc, char* argv[]){ if (argc>1){ int a=std::atoi(argv[1]), b=std::atoi(argv[2]); std::cout<<"a: "<<a<<", b: "<<b<<" "<<std::endl; //could be std::printf("a: %d b: %d", a, b); if it's //required as a C program. } …

Member Avatar for Lucaci Andrew
0
205
Member Avatar for new_developer
Member Avatar for Youler

for( char c : str ) result += m[c] ; It's a Java-like implementation of itration over a string, when char c will be at each iteration a character from the string. Here's what my compiler says: > range-based-for loops are not allowed in C++98 mode Also, perhaps this answer …

Member Avatar for Lucaci Andrew
0
158
Member Avatar for d.noora

Have you checked this thread? [http://www.daniweb.com/software-development/cpp/threads/182711/towers-of-hanoi-recursive](http://www.daniweb.com/software-development/cpp/threads/182711/towers-of-hanoi-recursive) Also this might be what you are looking for: [Click Here](http://lmgtfy.com/?q=tower+of+hanoi+recursive+solution+c%2B%2B)

Member Avatar for Lucaci Andrew
0
94
Member Avatar for panatda.tokhume

Line 28 long double Distance[NUM_Object][Object]; You got an error because Object as a variable is defined like this: double Object[NUM_Object][5]; You can't define it like that, because you're defining the size of that array, and thus you can't pass as number another array.

Member Avatar for panatda.tokhume
0
189
Member Avatar for marius2010

Ok, so you need, if, for example, 5 is inputed, to show you 7, and if 7 is inputed to shouw you 11, and so on and so forth. Well, we'll need a proof that you tried to solve your problem, so that we know where you're stuck. Post what …

Member Avatar for Lucaci Andrew
0
192
Member Avatar for robotnik

Line 35: char name[16]; Line 37: string name; You can't have two declaration of variables with the same name. This can be don when declaring functions, but with different arrities, but here, you either put char name[16] and string name1, or leave just 1 variable (I would suggest to leave …

Member Avatar for Lucaci Andrew
0
394
Member Avatar for bdl365
Member Avatar for Lucaci Andrew
0
94
Member Avatar for jlillie

Is there suppose to be a problem? Because, from what I see, everything works swell. Here's my output: ----You have selected option A---- Please enter the first name. John Please enter the last name. Doe Please enter the street address. Liberty Please enter the city, state and zip code. New …

Member Avatar for jlillie
0
180
Member Avatar for Jbvo

You could do it like this, passing not a copy of the vector, but it's adress, and work directly on the vector, from your function. Here's a quick example. void WordFunctions(string *pstr, vector<string*> &words){ words.push_back(pstr); } int main(){ vector<string*> a; for(int i=0;i<10;i++){ string* f=new string(1, (char)80+i); WordFunctions(f, a); } for …

Member Avatar for Mephesh
0
155
Member Avatar for RonKevin

cout<< "\nEnter Position:"; cin>>x; cout<< "\nEnter value to be inserted:"; cin>>y; cout<< "\nNew elements:"; cout<<arr[numb]; wouldn't that be cout<< "\nEnter Position:"; cin>>x; cout<< "\nEnter value to be inserted:"; cin>>y; if (x<numb){ arr[x]=y; } else cout<<"Invalid position."; cout<< "\nNew elements: "<<arr[x]<<endl;

Member Avatar for Lucaci Andrew
0
147
Member Avatar for Vegito1991

Have a look at the string class: [Click Here](http://www.cplusplus.com/reference/string/string/) Also, have a look at the algorithm class: [Click Here](http://www.cplusplus.com/reference/algorithm/) Use functions as replace/find. Also, here are two examples of funtions: removes the 1st occurence from the string: void rem(string &initialString, string whatToRemove){ size_t pos=initialString.find(whatToRemove); if (pos!=string::npos) initialString.erase(initialString.begin()+pos, initialString.begin()+pos+whatToRemove.length()); } replaces …

Member Avatar for Vegito1991
0
28K
Member Avatar for Echo89

I like your ideea. Here's what I have cooked up in 5 minutes: #include <iostream> #include <string> #include <vector> using namespace std; vector<string> explode(string inputstring, string delimiter){ vector<string> explodes; inputstring.append(delimiter); while(inputstring.find(delimiter)!=string::npos){ explodes.push_back(inputstring.substr(0, inputstring.find(delimiter))); inputstring.erase(inputstring.begin(), inputstring.begin()+inputstring.find(delimiter)+delimiter.size()); } return explodes; } int main(){ string a="a23<del>b345<del>b657<del>c65", delimiter="<del>"; vector<string> explodes=explode(a, delimiter); for (int i=0;i<(int)explodes.size();i++){ …

Member Avatar for Echo89
0
991
Member Avatar for danibecse

Well the reason you can't print a full sentence is because you write only 30 characters max: cout.write(msg,30); Have a look at the cout.write function: [Click Here](http://www.cplusplus.com/reference/iostream/ostream/write/) Instead you should write the entire msg: cout<<msg<<endl; Here, I put an example: this will read an entire file, and will display the …

Member Avatar for Daniel BE
0
3K
Member Avatar for manashmanash

Daniweb member rules state this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments** Show us your current code, than ask the question.

Member Avatar for Lucaci Andrew
-3
211
Member Avatar for Jwerb86

Seems fine: this is my output. Please enter the number of students in the database: 2 Enter name, student ID, and major... (follow each input with the 'enter' key until new prompt is seen): 1 2 3 Enter name, student ID, and major... (follow each input with the 'enter' key …

Member Avatar for Jwerb86
0
208
Member Avatar for Vish0203

Check this link: [Click Here](http://www.cplusplus.com/forum/windows/2024/) Also, there are numerous examples in the MSDN forums and on the site...

Member Avatar for Vish0203
0
275
Member Avatar for Carpetfizz

Here's a little example: #include <string> #include <iostream> int main(){ std::string answer; std::cout<<"1 or 2"; std::cin>>answer; // here you take the input, single word, till you hit enter, or ' ' is met. if (answer=="1" or answer=="1.") std::cout<<"one\n"; else if (answer=="2" or answer=="2.") std::cout<<"two\n"; else std::cout<<"Invalid choice.\n"; return 0; } …

Member Avatar for Carpetfizz
1
281
Member Avatar for pinaka

`strlen` function from the `#inclue <string.h>` header, from the C library indeed calculates the size of the strig, having as a final delimiter the `'\0'` character, but strings in C++ are objects, which are not handled having as the last character the `'\0'` character. If you do want to use …

Member Avatar for pinaka
0
182
Member Avatar for candicecandy

Daniweb member rules state this: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. Show us your code, than we'll help you.

Member Avatar for Schol-R-LEA
0
223
Member Avatar for STVG

I'm not going to give you speciffic code, but some useful links: [ifstream](http://www.cplusplus.com/reference/iostream/ifstream/) for opening files for reading. [ofstream](http://www.cplusplus.com/reference/iostream/ofstream/) for opening files for writing. [stringstream](http://www.cplusplus.com/reference/iostream/stringstream/) for tokenizing parts of the input stream. [getline](http://www.cplusplus.com/reference/string/getline/) for getting an entire line from a file, or from any other input stream.

Member Avatar for Ancient Dragon
0
163
Member Avatar for chris.vargas.773

A way to throw and catch a logic_error exception: int main(){ try{ throw logic_error("err"); } catch(logic_error& e){ cout<<e.what()<<endl; } return 0; } Also, have a look at the logic_error class from c++: [Click Here](http://www.cplusplus.com/reference/std/stdexcept/logic_error/).

Member Avatar for Lucaci Andrew
0
695
Member Avatar for Vish0203

Have a look at this: [Click Here](http://www.daniweb.com/software-development/cpp/threads/439460/replaceedit-a-specific-text-in-line-of-text-file#post1888886)

Member Avatar for sbesch
0
157
Member Avatar for lior.mor.73

Funny how a quick search on google shows a lot of answers: [Click Here](http://lmgtfy.com/?q=error+LNK1123%3A+failure+during+conversion+to+COFF%3A+file+invalid+or+corrupt) Also, you could see here some good answers to your problem: [Click Here](http://stackoverflow.com/questions/10888391/link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or-c)

Member Avatar for Lucaci Andrew
0
82
Member Avatar for anukavi

Also, you could do it by using a stringstream: int i=1001010100; std::stringstream token; token<<i; token.str(token.str().substr(0, token.str().size()-4)); token>>i; this will convert your int to a stringstream object, than, it will remove the last 4 digits and it will convert it back to int.

Member Avatar for Lucaci Andrew
0
1K
Member Avatar for chris.vargas.773

As **ravenous** pointed out, this assignment is about operator overloading. You'll need a TrashCan class where you specifically overload the operators, here you'll need to overload operator `+`, `-`, `>>` and `<<`, plus the boolean operators. So, first of all you'll need a class: class TrashCan{ //class stuff }; and …

Member Avatar for chris.vargas.773
0
120
Member Avatar for thammalatha

You put it as a function inside that Entry class. class Entry{ //clas stuff; FileSize(std::string Path) { std::ifstream Stream(Path.c_str()); if (Stream.is_open()) { int Start = Stream.tellg(); Stream.seekg(0, std::ios::end); int End = Stream.tellg(); Stream.close(); return (End - Begin); } return -1; } }; and inside the while you call the function: …

Member Avatar for thammalatha
0
338
Member Avatar for andrew mendonca

Here's a nice way of doing that: #include <iostream> using namespace std; #define SIZE 10 int main(){ double arr[SIZE], count=0; for (int i=0;i<SIZE;cout<<"Nr["<<i<<"]: ", cin>>arr[i++], count++) if (arr[i-1]<0) break; for (int i=0;i<(int)count;i++) cout<<"Nr["<<i<<"]: "<<arr[i]<<"\n"; return 0; }

Member Avatar for chaau
0
240
Member Avatar for andrew mendonca

> Am I doing the calculation correctly? What lines of code should I change? Line 3 and 4: int sum; int variance; change them to double.

Member Avatar for Lucaci Andrew
0
989
Member Avatar for kingwordforetaste

Daniweb member rules state this, among other things: **Do provide evidence of having done some work yourself if posting questions from school or work assignments**. We won't just hand you the answer.

Member Avatar for Lucaci Andrew
0
88
Member Avatar for izabella.pearson

bool leapYear(int year); { if (year % 4 ==0) return true; else return false; } get this function out of your main function, also indent your code... Another thing: your program has logic errors inside of it... #include <iostream> //Header Files #include <fstream> #include <string> #include <iomanip> using namespace std; …

Member Avatar for Lucaci Andrew
0
156
Member Avatar for Growl

> int IsPrime(unsigned long m) `'m'` is the parameter of the function isPrime, basically it's the number you want to check if it's prime.

Member Avatar for NathanOliver
0
111
Member Avatar for daino

> pkg.c:246: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'initted' line 246 from pkg.c, it seems that the expression is not valid, check again that code. Also, when dealing with large errors, look at the first errors, because some of the other errors are derived from the 1st …

Member Avatar for Lucaci Andrew
0
271
Member Avatar for thammalatha

> but i got the error 998 memory access violation Than you're using some pointer which points to a restricted memory area. Also, post the entire error, and do a debug of your program. See which pointer gets crazy...

Member Avatar for Lucaci Andrew
0
247
Member Avatar for schutzk21

Here's the buble-sort algorithm explained: [Click Here](http://mathbits.com/mathbits/compsci/arrays/bubble.htm) Try to think now how to apply this algorithm to work for strings and other items. Also, have a look at the STL sort algorithm: [Click Here](http://www.cplusplus.com/reference/algorithm/sort/)

Member Avatar for Lucaci Andrew
0
201
Member Avatar for tapuwa2002
Member Avatar for sujskiez

Wouldn't that be easier to have a Book class, which will hold information about a certain book, and then a repository, in which you'll add/update/store/delete/search for books? class Book{ string name, category; double price; public: Book(){ name=category=""; price=0; } Book(string name, string category, double price){ this->name=name; this->category=category; this->price=price; } void …

Member Avatar for arghasen
0
247
Member Avatar for moneypro

Have you checked this thread? [Click Here](http://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners).

Member Avatar for moneypro
0
130
Member Avatar for yamna1

Create a class named Bin_add (means stack class) that should contain following inline functions: • Add( ) To add two binary numbers bit by bit and display the sum. Should be a function from your class, that should be implemented in the class, and not aside, in some clauses in …

Member Avatar for yamna1
0
229
Member Avatar for jalpesh_007

> please help me how can i design such logic. Well, we're kinda confused about your explanation too. So, if you'll try to explain better what you're trying to accomplish inside that 2 for loops, we'll might help you, starting with these: > int number=no. to skip; and > but …

Member Avatar for jalpesh_007
0
186

The End.