353 Posted Topics

Member Avatar for jephthah

Edward's guess is that you get one star every 1,000 posts. That seems consistent, but Ed has been wrong too often in the past. ;)

Member Avatar for jbennet
0
387
Member Avatar for daniel88

> As a result, I thought that any changes to the array would be carried over outside the function. That's different. Arrays decay into a pointer to the first element and that's why you can change the elements: [code] #include <iostream> void foo(int a[]) { for (int i = 0; …

Member Avatar for Radical Edward
0
137
Member Avatar for Jennifer84

From what Edward has seen, you're using Windows Forms and not Win32. Without any of the bells and whistles of the standard message box, it's pretty simple to write your own message box dialog that closes after a set time. Here's a bare bones example: [code] #pragma once using namespace …

Member Avatar for Radical Edward
0
194
Member Avatar for touqra

Alternatively, you can make a class where the return values are fields and the object can be called like a function by overloading the () operator: [code] #include <iostream> #include <string> struct Name { std::string First; std::string Last; void operator()() { std::cin >> First >> Last; } }; int main() …

Member Avatar for vijayan121
0
104
Member Avatar for Jennifer84

The Columns property gives you access to individual column attributes: [code] dataGridView1->Columns[0]->Name = "Ed's Column"; [/code]

Member Avatar for Jennifer84
0
111
Member Avatar for wellibedamned

> i finally came up with this, it's a result of my first idea of nulling... Clever solution! Ed likes it, and to be honest, the only way Ed could improve on it would be to clean up the code a bit, make it tighter, and add Edward's style: [code] …

Member Avatar for wellibedamned
0
149
Member Avatar for Jennifer84

> for( int i = 0; i < checkedListBox1->Text->Length; i++) Edward doesn't understand how this is supposed to search the items. The Text property gives you the text of the currently selected item. Ed would expect something more like this: [code] for (int i = 0; i < checkedListBox1->Items->Count; ++i) …

Member Avatar for Jennifer84
0
145
Member Avatar for manzoor

Edward learned it like this: [LIST=1] [*]Player picks a number between X and Y [*]Computer guesses half way between X and Y [*]Player says higher or lower [*]Computer sets X to the guessed number if player says higher, or Y to the guessed number of player says lower [*]Computer guesses …

Member Avatar for Radical Edward
0
96
Member Avatar for dan_e6

++variable means that the variable is incremented by one and the new value is returned. variable++ means that the variable is incremented by one and the old value is returned: [code] #include <iostream> int main() { int variable = 0; std::cout << ++variable << '\n'; // Prints 1 std::cout << …

Member Avatar for William Hemsworth
0
14K
Member Avatar for dan_e6

> how do i make the array of authors bigger? If the size is going to be dynamic, you'll have a more pleasant time using vectors than arrays: [code] #include <string> #include <vector> struct library { std::vector<std::string> authors; }; [/code] Dynamically resizing arrays is tedious and error prone.

Member Avatar for dan_e6
0
265
Member Avatar for Jennifer84

What you're trying to do is concurrent processing. An easy way to do it is with .NET 2.0's [URL="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx"]BackgroundWorker[/URL] class to start a separate thread for the time intensive loop.

Member Avatar for Radical Edward
0
146
Member Avatar for toolbox03

What are you going to do with the values? Are you guaranteed that whitespace will separate the operators and operands? It could be really simple, or you might be better off writing a few classes that hold the raw equation data but still pass out extracted values. Depends on what …

Member Avatar for toolbox03
0
142
Member Avatar for Nemoticchigga

Edward prefers to pass data between forms using properties. Delegates work more with behavior than data, so they probably aren't a good match for what you want to do, which is something like this very incomplete example: [code] ref class Form1: Form { int _data; public: Form1() { _data = …

Member Avatar for Radical Edward
0
71
Member Avatar for Icebone1000

> in a windowed project, i noticed my couts are not showed in the screen Unless the program attaches itself to a console for you or you attach to a console manually in your code, you're stuck with the usual suspects: redirect stdout to a file or use a file …

Member Avatar for Radical Edward
0
88
Member Avatar for potentialdesign

> ok so i know all there is to know with text programming in c++. I doubt that. ;) Writing GUIs isn't the end all be all of C++ programming, and the lion's share of the work is done behind the interface. If you know all there is to know …

Member Avatar for potentialdesign
0
118
Member Avatar for Nemoticchigga

C++/CLI handles boxing and unboxing implicitly. Either of these work just peachy: [code] using namespace System; #include <iostream> int main() { String^ s = "123"; int x = Convert::ToInt32(s); std::cout << x * x << '\n'; } [/code] [code] using namespace System; #include <iostream> int main() { String^ s = …

Member Avatar for Nemoticchigga
0
100
Member Avatar for kxh29

Does your sprintf call look like this? [code] #include <stdio.h> int main(void) { int x = 123; char s[4]; /* Enough room for "123" +1 for null character */ sprintf(s, "%d", x); puts(s); return 0; } [/code] How exactly was it unsuccessful for you?

Member Avatar for Radical Edward
0
111
Member Avatar for Raptoricus

To expand on Lerner's answer, you're probably reading strings like this: [code] #include <iostream> #include <string> int main() { std::string name; std::cout << "Name your character: "; if (std::cin >> name) std::cout << "Hello, " << name << '\n'; } [/code] When cin works with the >> operator, it reads …

Member Avatar for Radical Edward
0
171
Member Avatar for tones1986

> This should do what i want correct? That's it. :) If you declare a pointer to BSNode<T>, that's all you have, a pointer. You can't reliably use that pointer until you set it to point to null or an address that reserves enough memory to hold an actual BSNode<T> …

Member Avatar for Radical Edward
0
113
Member Avatar for Run.[it]

> Horse h1(Distance(p)); This is an evil bug. C++ isn't seeing that line as an object definition, it's seeing the line as a function declaration. h1 is a function that returns a Horse object and takes a Distance parameter called p. It looks like a parameter because C++ treats the …

Member Avatar for Run.[it]
0
152
Member Avatar for Squeeker

> What is a literal array? Edward's guess is that a literal array is supposed to be an initialization list: [code] int x[] = { 1, 2, 3, 4, 5 }; [/code]

Member Avatar for Squeeker
0
185
Member Avatar for zsamus.love

> Why do I need to 'return' a pointer? Probably because returning a full object is too expensive. Pointers are usually smaller than the objects they point to, so passing and returning pointers can be more streamlined. > The author of the code writes in FunctionTwo "return theCat;" Why did …

Member Avatar for bugmenot
0
88
Member Avatar for Jennifer84

Edward has two suggestions. First, you can use the std::pair template from the utility header and store both the item text and check state: [code] std::vector<std::pair<String^, CheckState^> > ItemInfo; for (int i = 0; i < CheckedListBox1->Items->Count; ++i) { String^ text = CheckedListBox1->GetItemText(CheckedListBox1->Items[i]); CheckState^ state = CheckedListBox1->GetItemCheckState(i); ItemInfo.push_back(std::make_pair(text, state)); } …

Member Avatar for Jennifer84
0
152
Member Avatar for Jennifer84

The Items property gives you everything, and from there it's no trouble to get the checked state for each item.

Member Avatar for Jennifer84
0
649
Member Avatar for Jennifer84

If the code is run from more than one event, you should refactor it into a method: [code] void button1_Click(Object^ sender, EventArgs^ e) { // Stuff for button 1 Button2Stuff(); } void button2_Click(Object^ sender, EventArgs^ e) { Button2Stuff(); } void Button2Stuff() { // Stuff for button 2 } [/code] You …

Member Avatar for Jennifer84
0
260
Member Avatar for inamabilis

You're printing the address of the pointer, not the address of the memory pointed to. Remove the address-of operator from your cout statement and you'll get the address of the memory that new gives you: [code] cout<<"This room is stored at: "<< room <<endl; [/code]

Member Avatar for inamabilis
0
99
Member Avatar for amarhp

> how we can access fun2() using deleted pointer. You can't. Even if it works once, you can't rely on it to work always. You're seeing what's called "undefined behavior", where your compiler doesn't have to follow any rules about what's supposed to happen. The compiler could do what you …

Member Avatar for amarhp
0
118
Member Avatar for anbuninja

The >> operator is type safe, it knows what type you want and doesn't allow any characters that don't fit the type. What Edward means is that 'N' and 'n' aren't legitimate characters in an int. :) When you type one of those, cin goes into an error state and …

Member Avatar for anbuninja
0
118
Member Avatar for legendofme

You can simplify your loop by reading input in the condition. That way you don't have to prime the variable with [ICODE]cin>>letter[/ICODE] before the loop: [code] while (cin.get(letter) && letter != SENTINEL) { if (isupper(letter)) cout << letter; } [/code]

Member Avatar for Narue
0
95
Member Avatar for kiwihaha

Edward needs more information. Can you post the actual code you're using instead of paraphrasing? It's easier to optimize code than guess about what your solution looks like. :)

Member Avatar for dmanw100
0
118
Member Avatar for Ngup

> if ( m_TickList->Count.CompareTo > 15) Edward gets an error here too. CompareTo isn't even being treated like a function. > I am not sure how to fix this.. ICollection doesn't have an overloaded indexing operator, but you can use the GetByIndex method of SortedList: [code] if (Convert::ToInt32(m_TickList->GetByIndex(Z)) > HighestHigh) …

Member Avatar for Radical Edward
0
93
Member Avatar for trap-jaw

The STL list has a constructor that takes iterators. You can use that to initialize the list with the contents of your vector: [code] std::list<T> myList(vec.begin(), vec.end()); [/code] T is the same type as what vec holds.

Member Avatar for Radical Edward
0
44
Member Avatar for CodeBoy101

> It works because you assume the the character set is contiguous, and is basically US-ASCII Or Unicode, and Unicode is the future of character sets. Edward definitely recommends toupper, but when was the last time you worked on an IBM mainframe? ;)

Member Avatar for Radical Edward
0
112
Member Avatar for helloan

The hard part is working out how to get a random line from the file when you don't know how many lines there are. One way is to read the file once and count the lines, then use that count to pick a random number. A cooler way is a …

Member Avatar for jephthah
0
169
Member Avatar for want_somehelp

C++ doesn't directly support a static class. Are you talking about a class that only has static members and doesn't have a public constructor?

Member Avatar for vijayan121
0
465
Member Avatar for En1ro

You can still use ofstream, but you have to overload the << operator for your struct: [code] struct gydytojas { int gydid, amzius, specialyb, telefonas, asmkod; String vardas[25]; String pavarde[35]; String adresas[50]; friend ostream& operator<<(ostream& os, const gydytojas& obj); }; ostream& operator<<(ostream& os, const gydytojas& obj) { // Print the …

Member Avatar for mitrmkar
0
107
Member Avatar for n3XusSLO

For a beginner's C++ book, Edward recommends [URL="http://www.amazon.com/Accelerated-Practical-Programming-Example-Depth/dp/020170353X"]Accelerated C++[/URL].

Member Avatar for n3XusSLO
0
104
Member Avatar for Lotus_2011

[code] #include <iostream> #include <iomanip> #include <string> #include <bitset> int main() { std::cout << "Enter a binary number: "; std::string bin; if (getline(std::cin, bin)) { std::bitset<32> bits(bin); std::cout << std::oct << bits.to_ulong() << '\n'; std::cout << std::hex << bits.to_ulong() << '\n'; } } [/code]

Member Avatar for Lotus_2011
0
332
Member Avatar for acardiac

It's hard to help if you don't ask a question. Do you have any code that's not working right or do you not understand parts of the problems? Or did you just want someone to do your homework for you? ;)

Member Avatar for acardiac
0
262
Member Avatar for eaglehorse

The concepts are the same between Windows and Linux, but the details are different. You'll use different APIs and usually different libraries suited to the OS. There are portable libraries that work across multiple systems though, like Qt. Ed doesn't have much IDE experience on Linux, but Code::Blocks has a …

Member Avatar for Radical Edward
0
92
Member Avatar for En1ro

gydytojas is a struct, but you use it like an object. The problem is the same as if you tried to say [ICODE]int.value = 5;[/ICODE], and the fix is to define a variable of gydytojas to work with. :)

Member Avatar for En1ro
0
2K
Member Avatar for elementz

1: [URL="http://www.microsoft.com/express/vc/"]Visual C++ 2008 Express Edition[/URL] is good and free. [URL="http://www.codeblocks.org/"]Code::Blocks[/URL] is good and free IDE that comes with MinGW for the compiler which is also good and free. 2: [URL="http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html"]Thinking in C++[/URL] is two full books of good stuff about C++. The first book is more beginner stuff and …

Member Avatar for elementz
0
166
Member Avatar for David Wang

> How to pass the input of a textbox in Form1 onto Form2? I guess it depends on how you open the forms. If Form2 is the main form and controls Form1, you can use a property to get the login name: [code] // Put this in Form1 property String^ …

Member Avatar for Radical Edward
0
295
Member Avatar for himsk8r0

An if with more than one statement has to be wrapped in braces: [code] // This is OK! if (something) statement; // This is not OK! if (something) statement; statement; statement; // This is OK! if (something) { statement; statement; statement; } [/code] What's happening is the else part of …

Member Avatar for himsk8r0
0
89
Member Avatar for xtheendx

You should abstract your data into objects so that it's easier to make changes and the design is clearer. Right now you have three vectors of data that should be encapsulated in a student class: [code] class Student { std::string _firstName; std::string _lastName; int _score; friend std::ostream& operator<<(std::ostream& os, const …

Member Avatar for xtheendx
0
157
Member Avatar for Wza

The problem is that you need to know how long the string is before you can allocate memory for it, and you need to input the string and store it somewhere before you can get the length... :confused: That's why the string class is so great, it does all of …

Member Avatar for Radical Edward
0
131
Member Avatar for Black Magic

You're trying to compare itemNo with a character '0100', don't forget that single quotes mean character and double quotes mean string. But itemNo is an int, so no matter what you type, you're not going to match it. The same goes if you take the single quotes away because 0100 …

Member Avatar for Radical Edward
0
127
Member Avatar for wtf4096

Ed never liked nested classes. They feel inelegant to me, especially when data access is much more important than class visibility and it's easy to restrict class visibility to a single file: [code] // Assume you don't want CColor or CBox // to be visible outside of this file namespace …

Member Avatar for wtf4096
0
149
Member Avatar for mussa187

An array of char cannot be converted to char unless it is an array of 1. The reason is that one cannot fit more than one char value into a single char variable. You can process each char individually though. To do that, use two nested loops, one for each …

Member Avatar for Radical Edward
0
3K
Member Avatar for joanam

> I cannot compile programs in C++ done with previous versions (6.0) Visual C++ 6.0 allows both old style and new style iostream code. Your program might be including fstream.h instead of fstream, and you have to tell the compiler what namespace the name is in: [code] #include <fstream> // …

Member Avatar for joanam
0
2K

The End.