- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 83
- Posts with Upvotes
- 69
- Upvoting Members
- 42
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Re: > how can i avoid the 0 z in the value that is being displayed. You cannot. This is a limitation of the MaskedTextBox. Edward usually uses a regular TextBox and manages the format manually. For example, just a straight validation is super easy. [code] private void textBox1_Validating(object sender, CancelEventArgs … | |
Re: > convert any number that the user will enter and convert it in any base that the user will enter It is harder than you think. Converting to a base means knowing the alphabet of that base and using any special logic for generating values in that base. Functions like … | |
Re: That's why Edward puts as much code as possible in namespaces. Compilers are bad about including all kinds of unexpected stuff in the standard headers, so even if you don't include unistd.h yourself, iostream or another standard header might do it for you and create a name conflict. | |
Re: Sink the KeyDown event for the text box and you can cancel key presses if the character typed is not a digit. In fact, the documentation example for [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx"]Control.KeyDown[/URL] does exactly what you want. | |
Re: > That is not the best way to do it There's no such thing as the best overall way to do it. Your way might be better in Edward's program but worse in jephthah's, or vice versa. Though jephthah's function has the benefit of simplicity. :) > heres a better … | |
Re: [QUOTE=agdastidar;614505] [code]4) C/C++ doesn't exist[/code] This sentence do not have any meaning!!!!! Clarify.[/QUOTE] The logic is that C is a programming language and C++ is a programming language, but C/C++ is a misunderstanding of the difference between C and C++. Edward thinks this is just the language snobs being snobbish, … | |
Re: EOF doesn't have an ASCII value, it's required to be negative: [code=c] #include <stdio.h> int main() { printf("%d\n", EOF); return 0; } [/code] | |
Re: Get and set functions are just a public interface for getting read/write access to private data members: [code] #include <iostream> class EdRules { bool _isEdAwesome; public: EdRules(): _isEdAwesome(true) {} // Get function, gives read access to _isEdAwesome bool IsEdAwesome() const { return _isEdAwesome; } // Set function, gives write access … | |
Re: [B]Accelerated C++[/B] is the most recommended first book on C++ because it teaches C++ the way it will ultimately be used. All of the beginner books before it taught C with iostreams. ;) Edward reviewed [B]You Can Do It![/B] and was a little disappointed. The most useful part of the … | |
Re: Can you give an example of what you need to do? There are tons of ways to do what you want, but it depends on where in the XML you're searching and how you want to search. Do you want a full application that lets you do this, a search … | |
Re: Your code has too many problems for Ed to cover in detail right now, so here is a simple function that works using the library functions strcspn, strspn, and printf for any heavy lifting. If you cannot use strcspn or strspn, the problem can be broken down into the tasks … | |
Re: Do all functions from stdlib.lib give you a linker error? On a side note, Ed does not get warm and fuzzies from the name "stdlib.lib" because there is already a compiler-supported stdlib.h, which might have a corresponding stdlib.lib. | |
Re: system() returns an integer, but popen()'s first argument expects a string. What should be done depends on what you want to happen, but Ed would guess this: [code] ptr = popen(command, "r"); [/code] | |
Re: > I have done a little of it so far and it is correct up to this point This is true. It is very hard to get array declarations and a prompt for input wrong. :D Ed is inclined to believe that you accidentally pasted only a portion of your … | |
Re: > So should accessor functions always return const? Accessors should be const methods at the very least, because the object state isn't changed in the body: [code] double Point::getX() const { return x_; } [/code] That should clear up the error without forcing you to make the return value const. … | |
Re: > I heard that some anime was available for free (and more importantly legally) as a download for promotional purposes You can download fansubbed anime, and if it hasn't been licensed for sale in your language/country then it's only illegal in the "we won't come and get you" kind of … | |
Re: A "plain english" language was tried with COBOL. It didn't really work out. ;) The problems are verbosity and precision. Coming up with a precise grammar for the language makes it harder to understand than simple prose, and any language based on spoken languages will be much more verbose than … | |
Re: Take sign out of the equation, maybe? [code] int r = rand() % 190 - 95; [/code] | |
Re: Edward's team tried several tools including FogBugz, and finally settled on TargetProcess. | |
Re: On the local network you can just open a connection to the destination server directly. Distributed programming techniques are not necessary beyond possibly a UNC path or two. :) | |
Re: > isnt there a more elegant way? Right now, [URL="http://beta.boost.org/doc/libs/1_35_0/libs/assign/doc/index.html"]Boost::assign[/URL] makes it more elegant. [code] #include <boost/assign.hpp> #include <iostream> #include <string> #include <vector> using namespace std; using namespace boost::assign; int main() { vector<string> vec; vec += "this", "is", "my", "array"; for (vector<string>::size_type i = 0; i < vec.size(); ++i) cout … | |
Re: C++ uses the :: operator for scope resolution. [code] using namespace System::Windows::Forms; [/code] | |
Re: > doesn't the first example make the cp object global? Perhaps it could be described as global within the frmMain class. > I don't really want it (or need it) to be global. You might not want it to be, but you *do* need it to be if more than … | |
Re: The two programs are running as separate processes, so you need to use [URL="http://en.wikipedia.org/wiki/Inter-process_communication"]IPC[/URL]. | |
Re: If either method is faster, it will be memset(). memset() is a compiler provided function, and it might use tricks to run as fast as possible on the target platform. | |
Re: The ignore() method will flush cin, but it is better not to need to flush by always reading whole lines. :) Boost's lexical_cast<> makes it easy. [code] string teacherName; int teacherID; string line; cout << "Enter ID: "; getline(cin, line); teacherID = lexical_cast<int>(line); cout << "Enter Name: "; getline(cin, teacherName); … | |
| |
Re: > In my code I just wrote one for numbers. Good news! The NumberConverter actually works for any type with an overloaded << operator. Beyond recommending more of the STL and Boost, Edward approves of your code. ;) | |
Re: Too many parentheses, says Ed. ;) Look at the expansion of the macro and you will see something like the following. [code] (for (<init>; <condition>; <increment>)) { <body> } [/code] Control flow statements are not expressions that can be wrapped in parentheses. | |
Re: C++ does not have properties like C#. You can use methods though. [code] class Example { public: int parameter() const { return param; } void parameter(int value) { param = value; } private: int param; }; [/code] [code] Example text; text.parameter(value); cout << text.parameter() << '\n'; [/code] |