527 Posted Topics
Re: Through experimentation, I found that this is also legal-- [code=c++] #include <iostream> class Base { public: virtual void fn(){std::cout<<"fn base\n" << std::endl;} virtual void myfn(){std::cout<<"myfn base\n" << std::endl;} }; class Derived : private Base { private: void fn(){std::cout<<"der\n" << std::endl;} void myfn(){std::cout<<"myfn Derived\n" << std::endl;} }; int main(){ Derived d; … | |
Re: This thread reminds me of [URL="http://www.daniweb.com/forums/thread129415.html"]http://www.daniweb.com/forums/thread129415.html[/URL] | |
Re: Why not encapsulate what produces the sound in a thread and execute multiple versions of the thread (where upon initialization, you specify a String for the file to read to get the .wav file to play)? Edit: Oh I just noticed you're producing sound based on numbers and not a … | |
Re: [QUOTE=selvaganapathy;670734]I think Bitwise & operator can be useful. No & 2 == 0 means Odd and No & 2 == 2 means Even (here No is any number) Is this correct? I think it also using condition but different approach rather than modulus[/QUOTE] Though zero isn't an even number, it's … | |
Re: A few questions... First, why do you declare two arrays and define them full of spaces then iterate them through loops to assign space characters to them when they already have that value? You can reduce code-bloat by simply instantiating your arrays to have 12x12 characters. Furthermore the initial value … | |
Re: I think you need to be more concise with the requirements. You have 30 strings correct? Does this mean that they each cannot be more than 20 characters long (including the null terminator)? You must make your char[20][30] (or most likely char[30][20]) in pointer form, then convert it into an … | |
Re: Why not store the current time in a data type (like a long) when the key is pressed and when the key is released subtract the new time from the old time? | |
Re: Most companies that I know that use Cobol are moving towards Java. I'd guess that being, strictly a Java developer would be much more ideal in America, though I do not know about anywhere else. Then again if you want to companies migrating from Cobol to Java you would probably … | |
Is there any real different between using an union between two types and a reinterpret_cast between two types, for example-- [code=c++] #include <iostream> int main(){ union{ unsigned short *a; float *b; }; float value = 0.6f; b = &value; std::cout << *a << std::endl; unsigned short *s; float *f; f … | |
Re: Oh boy, there is a lot of wind being blown in this topic. To simplify things, everything sent to a function gets copied (or generates an object) if-- -An implicit cast is done (sending an int to a function that takes an Integer object for example (and for further clarity, … | |
Re: My first question to you is... Do you know what the different between an interface and an abstract class is? O_o | |
Re: Ok one big thing to note, before anything else-- [code=c++] vector<vector<double>> [/code] -- is not a portable statement because >> may (depending on the compiler) be analyzed as the right bitshifting operator and throw an error. You'll want to space out those symbols. [code=c++] vector<vector<double> > [/code] Edit: Also I … | |
Re: Although I haven't attempted it before, I'd assume you'd have a particular zone renderred on the screen with a type of "cover" over it. Either that or only render certain pixels ahead of the borders on a pane. The position of your character would, obviously determine when the screen will … | |
Re: Although I'm Atheist, I swear to god I got dumber from reading this topic. | |
| |
Re: I'd assume this is because of the padding factor and vtable pointers like you mentioned before. | |
Re: I'm pretty sure it's something along the lines of-- [code=java] Runtime.getRuntime().gc(); [/code] Or the long way-- [code=java] Runtime rt = Runtime.getRuntime(); rt.gc(); [/code] I do believe you can do the same using System instead of Runtime (without calling getRuntime - just System.gc() ) This simply suggests for the Garbage-Collecting threads … | |
Re: [QUOTE=ricss_madara;671481]class bubbleSort1{ public static void bubbleSort(int[] x) { int n = x.length; for (int pass=1; pass < n; pass++) { // count how many times // This next loop becomes shorter and shorter for (int i=0; i < n-pass; i++) { if (x[i] > x[i+1]) { // exchange elements int … | |
Re: You probably meant to post your question [URL="http://www.daniweb.com/forums/forum117.html"]here[/URL] | |
Re: Don't forget what classes are for! Classes are things capable of having behavior and encapsulating information. Encapsulated information can be data, but it's slightly beyond just that. Behavior can be considered a method, but it's slightly beyond that as well. If you're not worried about the stats of a unit … | |
Re: I strongly suggest that you re-read and brush up on C++ syntax before attempting this project. You may end up getting it to work as you are now, but it will either take an incredibly long time, have a lot of errors and/or cause you nothing but headaches. Even if … | |
Re: The error-- [icode]append(java.lang.String) in javax.swing.JTextArea cannot be applied to (PhoneDirectorySystem)PhoneBook_TextArea.append(list);[/icode] --is a fairly obvious statement. You could return the toString() of an element in the list and add to the JTextArea. It may even be better to have a toString method available for the entire list (if you're making a … | |
Re: [QUOTE=ff4930;671397]Classes are same as structs with the exception of default private and public.[/QUOTE] That's a good C++ definition, but that doesn't hold true for pure C. | |
Re: I like williamhelmswort's mouse-hook snippet. It always makes random amusement when I use it on somebody elses computer and watch them struggle to move the mouse XD | |
Hello I'm reading through Scott Meyer's book Effective C++, third Edition. I'm having an issue understanding Page 14, Item 2, paragraph 4. The below is a snippet of code with an explanation quoted from his book-- [code=c++] // Author: Scott Meyers class GamePlayer{ private: static const int NumTurns = 5; … | |
I'm enjoying the book Effective C++. It has highlighted things that I've looked over, never heard of, or never even though of before! However, even with this book my understanding of C++ still doesn't seem to be solid. For some time now I've been curious about how binary data is … | |
Re: [QUOTE=Risame;671865]Well guess I will have to do that, can't see any other way. I have spent like two days trying to make this work, and I guess I have had enough ^^ Thank you all for your help, hope my bad English hasn't been a problem ;)[/QUOTE] Off topic: You … | |
Re: Show us what you've come up with on your own. We help you, we don't code for you @_@ | |
Re: I'm assuming you're not allowed to use the Math library or recursion. If that's the case, use-- [code=java] static double power(double value, short exponent){ if(exponent >= 0){ // if exponent is greater than or equal to zero... double result = 1; // set result to one for(short i = 0; … | |
Re: To make this easier, you might want to consider using a Server class that encapsulates a ServerSocket and has an array of Sockets. The ServerSocket will be used to establish the Server, while the array of Sockets will be used for awaiting Clients (via ServerSocket.accept() ). Attached is a poorly … | |
Re: I made a correction but the code is slightly different. There were some errors in your code, such as assigning a String to the String[] reference and not an actual indice of the String array. Here's the code-- [code=java] import java.io.*; public class name{ public static void main(String args[]) throws … | |
I [I]still[/I] haven't figured out how to give someone neutral rep, yet I see everyone do it @_@ How is this done? I've tried clicking on the radio buttons multiple times in the add-rep form but no luck. Damn you geniuses at Daniweb programming! XP -Alex | |
Re: You may also want to consider using a BorderLayout so that your Menu bar will appear at the top within a JFrame-- [code=java] import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; public class JotPad extends JFrame { private JTextArea textArea; public JotPad() { super("Jot Pad"); setLayout(new BorderLayout()); //Arrange the Editing … | |
I've read up to the point where the author explains partial classes. I understand the general concept - they're used when a class is so big that it is better to split it across files. I created two .cs files. Let's say one is CS1.cs and the other is CS2.cs … | |
Re: I think you're making this assignment harder than it really is. Try to understand the problem first. You are accepting input into a method. The input can be any number except 0 alone. You WILL have data types to store information. At minimum, you will need a data type to … | |
Hi, my name is Alex. I'm fairly new to C# but apparently I may be required to know how to manipulate .NET Frameworks via C# so I am studying a beginners book and another book to thoroughly understand the language. The problem is that I am struggling to understand the … | |
Re: I believe your main problem is that you are trying to parse a String without numbers. When I compiled your code I got a number format exception. Here is what I did to eliminate the problem (to an extent) -- [code=java] import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*; import … | |
Re: [QUOTE=sciwizeh;660605]uh, if it is already an .exe, i think you can look at [URL="http://www.dreamincode.net/forums/showtopic21813.htm"]this[/URL][/QUOTE] I'm really not sure if the link you provided will be helpful, because in Java you cannot make native calls to C++ code directly (or any program that has potential access to memory) within an Applet … | |
Re: Ok, you're confusing the phrase "do what I mean" with Java syntax. I strongly recommend for you to read the first link presented here on this forum and get some pointers on how to code syntactically correct Java-style. Also it would help if you posted your code in Code-tags-- [url]http://www.daniweb.com/forums/misc.php?do=explaincode&TB_iframe=true&height=400&width=680[/url] | |
Re: Use code tags please, otherwise if people try to copy/paste your code they will most likely get # symbols that they'll have to manually delete. Not to mention that there's no telling if the code will be indented properly (which means more work for people testing your code). [url]http://www.daniweb.com/forums/misc.php?do=explaincode&TB_iframe=true&height=400&width=680[/url] | |
Re: [QUOTE=maddogsprofiles;668107]I've been on Scriptlance for the past few days, trying to get a programmer for my plurk clone and I have noticed that a lot of the programmers bidding are from India, I thought a lot of my replies would be from the US, but my question is though, can … | |
I'm having some trouble on deciding to purchase Scott Meyer's Effective/More Effective C++ books or Herb Sutter's Exceptional/More Exceptional C++. I'm assuming both cover the same concepts, but I could be wrong. Opinions/Votes please from C++ programmers that found the one they read useful. There's also an option for both … | |
Re: Yes, including a throws on the end of main is considered bad programming practice since nothing can really catch an error generated from main and handle it afterward. Only use throws on the end of main to save time when practicing something particular without bloating the code in try-catch blocks. … | |
Is the [X] at the top right corner part of the JApplet or container with the JApplet? I need to make an action happen when the user attempts to close out of the JApplet and I'm not sure of how to properly access the window-closed button within JApplet context. Thanks … | |
I'm having a Focus issue when running a Swing application. There are 4 buttons visible on the JApplet. I have an implementation that allows the user to make keyboard and mouse events in the JApplet. The problem is that I can use the keyboard and mouse events when the program … | |
Re: [QUOTE=SonxQ7;665790]Is there a Template Class in Java as in C++, or is Object class in Java similar to Template class in C++ or at least the concepts...[/QUOTE] Study Generics/Erasure in Java. It's similar to C++ Templates, but has a major compile-time difference. In Java instances of Erasure types, as the … | |
Re: Use the DecimalFormat API [url]http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html[/url] | |
Re: [QUOTE=JaksLax;665393][B]I cant figure out why it doesnt recognize first and last. Any ideas?[/B][/QUOTE] Uh... first and last are local parameters to the constructor in the Person class. They are not at all visible to the derived class Employee. If you want this to work you'll have to change Employee's constructor … | |
Re: Do you simply want a separate pointer for the data? If so then this might work-- [code=c++] #include <iostream> #include <vector> using namespace std; typedef struct { void *map; } XE_MAP; typedef struct MAP_LAYER { MAP_LAYER() { map = (XE_MAP*)malloc(sizeof(XE_MAP)); map->map = (void*)data; cout << "Data is at " << … | |
Re: To invoke function of a class through pointers, you may have to use a pointer to a member function. Your vector will have to store MtFP's instead of regular FP's. |
The End.