527 Posted Topics
Re: [QUOTE=zoner7;630743] What in the world does line 20 do?[/QUOTE] 19: SimpleCat::SimpleCat(int age, int weight)[B]: 20: itsAge(age), itsWeight(weight)[/B] {} The bolded part denotes an initialization done during the Constructor call. itsAge is set to age and itsWeight is set to weight when the constructor is called (sort-of like a pre-initialization). I … | |
This isn't exactly a thread about a particular question, but a thread that may help people with memory dynamically allocated/deallocated during runtime. The below example goes over pointers in multiple dimensions-- [code=c++] #include <cstdlib> #include <iostream> /** This program can be used to determine whether pointers are deleted or not … | |
Re: Instead of using the double generator from the Math class you can try using the Random class from java.util.Random extension. I modified your code to implement it-- [code=Java] import java.applet.*; import java.awt.*; import java.awt.event.*; import java.lang.Math.*; import java.util.Random; /* *Author: John Pycroft *Date CR: 15/6/2008 *Date LM: 15/6/2008 *Name of … | |
Re: When your program is running and you need to allocate memory WHILE the program is running, dynamic memory allocation is the way to go. Think of how restrictive programs would be if they always had to perform on limited memory. There are more benefits to dynamic memory, but this is … | |
Re: [code=c++] #include <iostream> #include <fstream> #include <string> #include <iomanip> #include <time.h> using namespace std; void Hangman(); void LeftArm(); void Head(); void RightArm(); void Body(); void LeftLeg(); void Gallows(int count); void DisplayAWord(string guessword); void revealword(char letter, int position,string fileword, string guessword); void secret(string fileword); void hidden (string fileword); char Question (); … | |
Re: You could also create multiple timers and register an action listener on your class. The Timer object is meant to activate the action listener of the class in the specified milliseconds. So you can have one actionlistener and multiple timers with different commands. About your question of whether you need … | |
Is there a website that has some kind of GUI or application that allows users to enter statements like-- delete delete [] for... n elements... delete arr[n] --etc so that they can learn good memory management? I sifted around some free ebook sites and found one but the link to … | |
Re: [QUOTE=Nemoticchigga;630631]I have a program with a bunch of threads running. I kill them all at the end of the program. I have stepped through and seen them all abort. Is there a way to see (since I cant when stepping through) which thread it is? I can see the process … | |
Re: [QUOTE=Sukhbir;630219]Hi All, If i have choice to either use simple array(char a[]) or map. Which one i shall use, whether array or map. i need to know wich technique will give better performance. As per my requirement i will insert the element in array/map, find the element based on index. … | |
Re: [QUOTE=USUAggie;629433]Sorry I was not very clear, I actually did not understand the question fully myself. Basically, the children of a node just become reversed: [B]so if node t has a kid named a and e, and a's right sibling is e, t would point to e and then a would … | |
Re: [QUOTE=williamhemswort;629208]This is what you do when your bored ?! I suggest you try learning the Win32 API to be able to make proper window applications, and then mabey move on to MFC when you get the hang of that. From there you should be able to make basic games / … | |
Re: Hello! Have you heard of the interface Comparable? It allows you to compare like-objects with its implementation. [code=java] public static void sort(Comparable[] values, int start, int end) [/code] If your class implemented Comparable you would be forced to include a method called compareTo(Object o) The reason this is nice is … | |
I'm getting a really odd error in my program. The lvl value retains its initial value if it's left alone, but when the program runs after you've assigned it a value it get's a ridiculous number... then the previous number after another assignment... and the process continues. Here's the code. … | |
Re: [QUOTE=nemom;627855]Hello everybody,, this is a simple java method that calls itself,, [code=java]class ex{ public static void main(String [] args){ simpleMeth(5); } static void simpleMeth(int i){ if(i != 0){ rec(--i); System.out.println(i); } } } [/code] If you follow the the codes you will find after sending number (5) to the method … | |
Re: [QUOTE=Yuichi;628769]Hi guys,i am new to both c++ and this forum...I got a problem with a question i m supposed to do.I am supposed to create a queue system but i am stuck at a point where i can't add numbers to the queue system.This is the question... You have been … | |
I hear this argument a LOT and hear that templates/generics are far more superior in code production than virtually-driven classes. I still don't understand this. I've heard the virtual functions cause problems for performance and that the solution is always to use Templates/Generics. Do they mean that it is better … | |
Re: [QUOTE=Ancient Dragon;628665]It compiled without error for me. What error message(s) did you get with your compiler. I used VC++ 2008 Express.[/QUOTE] I don't think he meant that it had errors but that he couldn't build the files in separate .cpp files outside of a project. My question to the original … | |
Re: You're asking to return a pointer when you're really returning the address of an object that has fallen out of scope-- [code=c++] T value = elems.back(); //T value is a temporary object elems.pop_back(); return &value; //the object in value fell out of scope before return [/code] I'm honestly surprised you … | |
Re: Gotta love the SWAP macro too... [code=c++] #define SWAP(a, b) __typeof__(a) temp; temp = a; a = b; b = temp [/code] | |
Re: [url]http://www.cs.gmu.edu/~white/CS540/HW/first_hw1.html[/url] | |
Re: Odd, I'm not getting that error at all... Did you include the preprocessor directives for cstdlib and iostream? Also are you using namespace std? It ran fine for me, no weird operator errors. | |
I don't understand... I thought that it would be functional based on the logic, and I was fairly careful with my syntax but it's still not working. Sometimes values will compare to as being "equal" even though they're not. I'm using troolean compareTo method (an int, returns -1, 0 or … | |
I was working with my own "Vector"-like class and thought about something. If I use the [] operator and return a reference, is there any way to mark that indice when a value is assigned to it? For example.. if I want to make a trim function that removes the … | |
Whenever I try to declare a "Regular Expression" while including symbols like "+", "-", "*", the match is done based on how those operators work. Now, when I try to use the regex API via combining those operators with backslash or \Q and \E I get the error message-- "...Illegal … | |
Re: I tried compiling the code but I think some of it is written in french? O_o | |
Re: [QUOTE=mikelle;628051]I'm not sure how to approach this problem.. mostly with the while statement.. Download the original attachment The Problem: Write a program on timber regrowth of a harvested forest. The user is to enter the total number of acres in the harvested area, the number of acres which were left … | |
I don't understand what is happening to my program... I have a feeling that private members are marked private for a reason, because I'm having a serious error with accessing base-class data types via inheritance and declaring friends within classes... If you run the test program after attaching the header … | |
Right now I feel fairly unlearned with dynamically allocating memory... even after doing so several times and doing projects that require one to dynamically allocate memory for classes and primitive types. Basically, how does one research allocation for different scenarios such as... [code=c++] #include <cstdlib> #include <iostream> using namespace std; … | |
Re: [QUOTE=Magda;626305]Hi all, Thanks for your help so far ! I hope you wont mind if I ask you for help again..Being brutally honest I must admit that I didnt study the later material of the course properly what now effects in huge lacks in my knowledge...:'( after the Map and … | |
Re: [QUOTE=joshmo;626492]I am studying stacks, queues, and heaps at the moment but i dont know how i can apply this in real life. Well my question is how can these may i say operations helpful and when are they really needed as opposed to others. I hope you can get my … | |
Re: I was just going to say "wouldn't implementing a scientific notation class be optimal?" But I guess we're staying away from STL's so... I think your instructor may expect you to represent the factorial as a collection of other factorials or.... as a string. Either that or you will have … | |
Re: That's the beauty of c++ though, learn how to custom build your own "helper" classes and you'll become more efficient at programming. | |
Re: [code=c++] char FilePath[] = "C:\\Dev-Cpp\\keylogger.exe"; [/code] I think your problem is here, where you use \\ instead of // for your file path checking. Try this-- [code=c++] char FilePath[] = "C:/Dev-Cpp/keylogger.exe"; [/code] Although I'm not too sure why you have two slashes instead of one. also when creating an array … | |
Re: [QUOTE=warrior16;623896]Interesting. To check the array that is made of Strings, you just go if(wordlist[1] = "whatever the name is") [/QUOTE] Not quite, you never want to use the assignment operator for a boolean expression since it will always be true if the value stored isn't null. You may want to … | |
Re: Did you even start/try? Honestly these look like more than just beginner questions to me. In order to understand data structures, file io, and string manipulation you need to be pretty far into the course. Are you telling me that you haven't been paying attention this entire time? | |
Re: Why not make an inner class extend from the color class and overwrite the toString() method? | |
Okay so I have a program that tests for collisions using a complicated and 80% accurate method, but I want 100% accuracy. Like someone posted earlier about shapes colliding into each other, I realized that there will be cases where my method wont work. However, I've looked into a calculus … | |
Re: [QUOTE=Tigran;624764][B]Hi guys, 1) Why do some people set a "_" before things like function names? I've seen this a few times, and asked myself if it had or didn't have any use.[/B] [/QUOTE] A lot of this _class naming is done for library purposes, but it isn't restricted to that. … | |
Re: [QUOTE=Jishnu;624583]Hello, I'm getting a compile-time error in jdk1.2.1 which says "Identifier expected" and points to this line in the code: [CODE]Vector<Fish> fishes = new Vector<Fish>();[/CODE] Aren't vectors supported in jdk1.2.1? I'm unable to catch the problem.[/QUOTE] Vectors may be supported in jdk, but they may not be supported with Generics. … | |
Re: Can you post your code please? It's unlikely that we can help you if you don't. | |
Re: Keep in mind that no matter which object you create, you must increment n so that your inventory is updated with the amount of objects created. Basically whenever you add a book, CD or DVD you have to increment n. Just take a look at your destructor, it deletes pointers … | |
Re: [QUOTE=daviddoria;622701]Anyone know where I can get an implementation of this? Some code to read in a set of vertices/triangles and then do some simple intersection tests? If you can point me in the right direction that'd be great! Thanks, Dave[/QUOTE] Seems like you can easily do this by emulating a … | |
Re: [QUOTE=daniel88;619446]Hi guys, This may well have been covered in another post and, if so, feel free to direct me to that one. Also, I hope that I am in the correct section! I am approaching the end of my semester and face the upcoming exams. Obviously most of the work … | |
Re: > I am preety lazy to use merge sort. The trick is to have an array of index which originally has numbers from 1 to n. and sort it along with the array. Here is a simple code. #include<iostream> using namespace std ; int main ( ) { int a[] … | |
Re: From what it looks like, your ints ldepth and rdepth are declared then initialized to a value returned by a function. Because the function must perform functionality/calculating, the variable doesn't receive a value until the function is complete. The variable will never be "complete" until one of the nodes it … | |
Re: [url]http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html[/url] | |
Re: [QUOTE=darkagn;623378]Could you just put a simple if-statement in your mouseExited method? [code=java] public void mouseExited(MouseEvent e) { if (e.getSource() != this.closeButton) { // do your current code here } } [/code][/QUOTE] Either that or create a thread in your mouse-exited to wait a certain amount of seconds before making the … | |
Re: You'd need to create a button that has an actionListener that, upon activation, will access a reference to whichever pane is "focused" then you'll need to access that pane's window-hiding command (you'll have to pick the command that hides the window permanently to emulate a close). | |
Correct me if I'm wrong but... Each time I declare an object without assigning it a value, I am instantiating it (so long as the valid constructors is called upon doing so--) like... [code=c++] Triangle tri1 (3, 4); [/code] and this object exists on the stackk but only for the … | |
Re: First of all you don't need to keep posting a new topic each time you reattempt to fix your code. If you reply in your old topic people will see the bump and get back to it. People will be less likely to help you if you keep creating new … |
The End.