527 Posted Topics

Member Avatar for zoner7

[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 …

Member Avatar for ff4930
0
88
Member Avatar for Alex Edwards

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 …

Member Avatar for vijayan121
0
102
Member Avatar for Person1873

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 …

Member Avatar for Person1873
0
126
Member Avatar for salman213

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 …

Member Avatar for Cait
0
104
Member Avatar for JackDurden

[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 (); …

Member Avatar for VernonDozier
0
88
Member Avatar for new_2_java

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 …

Member Avatar for new_2_java
0
112
Member Avatar for Alex Edwards

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 …

Member Avatar for mitrmkar
0
115
Member Avatar for Nemoticchigga

[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 …

Member Avatar for Alex Edwards
0
85
Member Avatar for Sukhbir

[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. …

Member Avatar for Alex Edwards
0
4K
Member Avatar for USUAggie

[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 …

Member Avatar for Duoas
0
230
Member Avatar for Black Magic

[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 / …

Member Avatar for Prabakar
0
125
Member Avatar for Spunkerspawn

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 …

Member Avatar for Spunkerspawn
0
148
Member Avatar for Alex Edwards

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. …

0
98
Member Avatar for nemom

[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 …

Member Avatar for nemom
0
171
Member Avatar for Yuichi

[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 …

Member Avatar for Yuichi
0
208
Member Avatar for Alex Edwards

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 …

Member Avatar for Radical Edward
0
1K
Member Avatar for Metalsiege

[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 …

Member Avatar for Ancient Dragon
0
108
Member Avatar for USUAggie

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 …

Member Avatar for Alex Edwards
0
143
Member Avatar for cecyl

Gotta love the SWAP macro too... [code=c++] #define SWAP(a, b) __typeof__(a) temp; temp = a; a = b; b = temp [/code]

Member Avatar for vijayan121
0
128
Member Avatar for Alex_
Member Avatar for Alex Edwards
0
114
Member Avatar for QuantNeeds

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.

Member Avatar for QuantNeeds
0
795
Member Avatar for Alex Edwards

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 …

Member Avatar for Alex Edwards
0
115
Member Avatar for Alex Edwards

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 …

Member Avatar for Radical Edward
0
214
Member Avatar for Alex Edwards

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 …

Member Avatar for Alex Edwards
0
121
Member Avatar for comply or die
Member Avatar for Ancient Dragon
0
123
Member Avatar for mikelle

[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 …

Member Avatar for Nick Evan
0
269
Member Avatar for Alex Edwards

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 …

Member Avatar for Alex Edwards
0
163
Member Avatar for Alex Edwards

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; …

Member Avatar for Alex Edwards
0
75
Member Avatar for Magda

[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 …

Member Avatar for Ezzaral
0
337
Member Avatar for joshmo

[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 …

Member Avatar for Alex Edwards
0
140
Member Avatar for ice661666

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 …

Member Avatar for tesuji
0
139
Member Avatar for ff4930

That's the beauty of c++ though, learn how to custom build your own "helper" classes and you'll become more efficient at programming.

Member Avatar for Duoas
0
171
Member Avatar for pwnz32

[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 …

Member Avatar for pwnz32
0
3K
Member Avatar for Futbol10

[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 …

Member Avatar for Futbol10
0
115
Member Avatar for instructor_c

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?

Member Avatar for Nick Evan
0
177
Member Avatar for warrior16
Member Avatar for Alex Edwards
0
122
Member Avatar for Alex Edwards

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 …

Member Avatar for Alex Edwards
0
132
Member Avatar for Tigran

[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. …

Member Avatar for Alex Edwards
0
231
Member Avatar for Jishnu

[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. …

Member Avatar for Jishnu
0
101
Member Avatar for mariaczi_pl
Member Avatar for gctarzana

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 …

Member Avatar for Sky Diploma
0
2K
Member Avatar for daviddoria

[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 …

Member Avatar for Alex Edwards
0
224
Member Avatar for daniel88

[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 …

Member Avatar for hammerhead
0
290
Member Avatar for AnjaliAnuradha

> 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[] …

Member Avatar for mitrmkar
0
121
Member Avatar for peachslasher

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 …

Member Avatar for Alex Edwards
0
118
Member Avatar for orcboyx

[url]http://java.sun.com/javase/6/docs/api/javax/swing/JFrame.html[/url]

Member Avatar for eranga262154
0
74
Member Avatar for bops

[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 …

Member Avatar for Ezzaral
0
575
Member Avatar for TheWhite

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).

Member Avatar for Ezzaral
0
120
Member Avatar for Alex Edwards

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 …

Member Avatar for Alex Edwards
0
218
Member Avatar for beelzibub

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 …

Member Avatar for Alex Edwards
0
160

The End.