- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 8
- Posts with Upvotes
- 6
- Upvoting Members
- 7
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
35 Posted Topics
For an electronics project, I have to access the TxD, RTS and CTS pins of a serial port individually. Well, any 3 pins could be used, but those 3 are preferred. All I've been able to find on the microsoft website are functions to access the serial port as a … | |
Re: Change line 55 from [icode]cin >> newTeam, sizeof(newTeam), stdin;[/icode] to [icode]cin >> newteam;[/icode] Line 74 still has the same problem. You fixed your cout statement on the line above, but not the cin line. I'd follow jonsca's advice and read up on cin/cout.. Well, short version: [CODE=CPP]int a, b; cin … | |
[I]Assignment:[/I] Write a function zet_om_naar_getal(getal) that calculates the binary representation from a decimal number as a string, using recursion. [I]What I have so far:[/I] [CODE=CPLUSPLUS]string zet_om_naar_binair(double getal) { string binair; if(getal >= 1) { binair += '0' + static_cast<int>(getal)%2; binair += zet_om_naar_binair(getal/2); } else if(getal > 0) { double dubbel … | |
Re: From what I can see the error is in your stack/queue declaration. You're adding charachters, not strings.[CODE=CPP]queue<char> aQueue; stack<char> aStack; //instead of queue <string> aQueue; stack <string> aStack; [/CODE] | |
Re: FirstPerson's code works, but it's bad coding practice to hard code the ASCII numbers. Also stated in your assignment, if you are to use character literals you just have to change the numbers to letters. [CODE=CPP] bool isLowerCase(char ch){ //Check if the letter is between a to z return ( … | |
Re: [CODE=cpp] bool quit = false; while(!quit) //And some other conditions, obviously { //Do something if(break) quit = true; //Break out of the loop by failing the condition for the loop, without using break } [/CODE] | |
Re: You missed the point in references. When a variable is passed to a function, a copy is made, so you can't change the original. When a pointer, or an array, is passed you CAN change the value, it just tells the function where to find the original. To be able … | |
Re: From what I can tell from the error your account class has no default constructor. When you declare a constructor for a class, the compiler expects you to supply all constructors, including the default constructor. checkingaccount inherits from account, which means it will first contruct an account object and then … | |
Re: I guess you're not familiar with this forum, so I'll just refer you [URL="http://www.daniweb.com/forums/announcement8-2.html"]here[/URL]. | |
Re: [QUOTE=ured;1033939]Thanks FIRSTPERSON....but how do I copy from the string starting at stringIndx to its size?[/QUOTE] Use substr from the string library. If you want it as an int you can use atoi from there. [CODE=CPP]string number = S.substr(stringIndx); //Copies from stringIndx to end into number int num = atoi(number.c_str()); //Get … | |
Re: An ofstream is an object, not a function. To open a file using ofstreams you first create the object, then open the file. Like so: [CODE=CPP]ofstream file; file.open("a.txt"); //Do something file.close();[/CODE] In your case you could place it in a loop. You'll have to make a string object to get … | |
Re: Function calls always require paranthesies(), even if there are no parameters. In your case you'd have to do something like: [CODE=CPP]int celcius, farenheit; cel_to_far(celcius, farenheit); cout << "When you have " << celsius << " degrees, that is equal to " << farenheit << " degrees, Fahrenheit" << endl; cout … | |
Re: Havn't tested this, so there might be a few errors: [CODE=CPP]void split_string(const string& src, vector<string>& dst, char split) { int startPos = 0, endPos = src.find(split); while(endPos != string::npos) { dst.push_back(src.substr(startPos, endPos-startPos)); startPos = endPos + 1; endPos = src.find(split, startPos); } }[/CODE] | |
Re: You should either include "hashTable.cpp", or have the class declaration and implementation in the same file(as firstPerson already pointed out) | |
Re: You might want to change your destructor. [CODE=CPP]delete [] st;[/CODE] instead of [CODE=CPP] delete st; [/CODE] You'll be creating memory leaks if you don't. | |
Re: I'd switch the order of printing around. First print a comma, then print the number. This does require you to find the first number beforehand, though. [CODE=CPLUSPLUS]void set::Display() const { cout << '{'; int i = 0; while(i < setlist.size() && setlist.at(i) != true) i++; if(i != setlist.size()) cout << … | |
I've created a class, Category. [CODE=cpp]#ifndef CATEGORY_H_INCLUDED #define CATEGORY_H_INCLUDED #include <string> using std::string; enum Type {Integer, Double, Bool, String, Date, Time}; class Category { public: Category() : itsType(String) {} Category(Type type) : itsType(type) {} Category(string name) : itsName(name) {} Category(Type type, string name) : itsName(name), itsType(type) {} ~Category() {} void … | |
I'm having trouble getting the right operator to be accessed using polymorphism. The code below is a simple representation of the problem, but it should get the point across. [CODE=CPLUSPLUS]//Horse.h #ifndef HORSE_H_INCLUDED #define HORSE_H_INCLUDED #include <iostream> #include <string> class Horse { public: Horse() {} Horse(int age) : itsAge(age) {} virtual … | |
Re: [code=cpp] class complex { friend ostream& operator<<(ostream& output, const complex& V); private: double REAL; double IMG; public: complex(); ~complex(); //Added functions double GetReal() const {return REAL;} double GetImg() const {return IMG;} }; //IMPLEMENTATION of <<: ostream& operator<<(ostream& output, const complex& V) { output<<"("<<V.GetReal()<< "," << V.GetImg()<<")"; return output; // for … | |
Re: I'm guessing you're looking for something like this. You have a class [i]School[/i], each School having a specified amount of [i]Student[/i]'s. [code=cpp] class School { private: String schoolName; vector<Student> itsStudents; public: //Put functions here //Like: String GetName() const {return schoolName;} }; class Student { private: String name; String adress; int … | |
Re: I'm supposing you're obtaining user input by using: [code]cin >> name;[/code] If you are, I suggest you read [URL="http://www.daniweb.com/forums/thread90228.html"]this thread[/URL]. The problem with cin is it only takes input till a whitespace is found, so you're only using the first word. | |
Re: [code]if( s=="m" || "male")[/code] Should be [code]if( s=="m" || s=="male")[/code] You have to compare it to the s variable again, else it will evalute "male" as a char array, which will always return true. | |
Re: Suppose the annual interest rate is 10%. It means you'll get 10% of whatever amount is stored on an annual basis. Be it the case you have 100$ deposited for a whole year at 10% interest rate. [code=cplusplus] int deposit; float interestRate, interest; cin >> deposit; //In this case 100 … | |
Re: There's nothing wrong with the program. You're succesfully opening it. To have the effect you want, you first need to get the data from the file then write it back to the screen. | |
Re: There's plenty of programs out there which record keyboard input and mail it through. I'm supposing you could use one of those. Note, I wouldn't trust all of those to be safe... | |
Re: sqrt(-1) = 1 * i Where i can't be defined. You can't calculate it. So if you were to return it as a result, it'd have to be a string like this: "<Real part> + <Imaginary part> * i", in this case it would leave "0 + 1 * i", … | |
Re: Sounds like you want something like this... Note that this code won't compile. It was just an example, with it still being your work to implement it. [code=cplusplus]class Ship { std::String GetType() {return "Ship";} } Ship aShip; std::cout << "This is a " << aShip.GetType();[/code] | |
Re: The only way I know is by using the System::Drawing namespace. It allows you to define brushes, and with it fonts, colors, text formatting(including bold). [code=cplusplus] System::Drawing::Brush^ testBrush = Brushes::Black; //System::Drawing::Font::Bold System::Drawing::Graphics::DrawString("Use this to draw a string", someFont, testBrush, somePoint);[/code] You should be able to add the bold property to … | |
Re: You could try this, worked for me in a StripToolMenu. [CODE=cplusplus] this->richTextBox1->Checked = true; this->richTextBox1->CheckState = System::Windows::Forms::CheckState::Checked //You can leave System::Windows::Forms:: off if you're using the namespace[/CODE] Sorry, thought you were asking about getting a row to appear as checked. Either way, I'm supposing there should be something similar to … | |
Re: You should at least try to write some code if your own... If you already have, post it. If you're really clueless on how to even start on this, you need a method to generate a random number(stdlib.h includes one) and a loop. | |
Re: You can find a pretty good reference [URL="http://www.cplusplus.com/reference/"]here[/URL]. Doubt it's complete, but it has most commonly used libraries. | |
Using a windows forms application, most appropriate thing to use seems a listbox. Been searching around a bit, but I never found anything which seemed to explain it thoroughly. The idea is to load data from an XML file, and then display it in a list, presumably a listbox. Basically … | |
Re: Just thought I'd throw in that little bit I do know... In your Point destructor, you're freeing the memory allocated by the coords_array. But what you're actually doing is only deleting the first entry of the Array. All the rest will be stored. To delete all of it's elements you … | |
Well, the basic structure is a form which uses multiple classes defined in seperate files. Below is my controller class which is supposed to keep track of which files are opened. It's included in both the form and the [i]Map.cpp[/i] file, which contains all Map function implementations. I'm supposing these … | |
I made a win32 application in Visual C++ 2008 using the Windows Forms Application. But for opening files, and saving eventually, havn't gotten to it yet, I was creating some basic classes in other files. The odd thing is the [i]stdio.h[/i] file seems to be working differently in VC. I … |
The End.