527 Posted Topics
Re: Friendship isn't inherited. You declared a private constructor for the Lock class, in which it is only accessible either within that class or within a scope that has the right to access that Constructor. Also because you've defined a constructor there is no default/dummy constructor provided. Because First is a … | |
Re: [QUOTE=lil_panda;642468]Are there, in any way, shape, or form, pointers in java like there are in C and C++? If so, do I declare them the same way as in C++? My 873 page book doesn't explain pointers.[/QUOTE] Technically, all reference-variables in Java are pointers. The only differences are that you … | |
Re: True solution - study the DecimalFormat API here -- [url]http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html#setMaximumFractionDigits(int[/url]) Here's a complicated and unrecommended alternative solution-- [code=java] import java.text.*; public class Time_To_Format{ public static void main(String[] args) throws Exception{ System.out.println(Time_To_Format.<Double>truncate(new Double(2.444444), 2)); } static <E extends Number> E truncate(E num, int knockoff) throws Exception{ E e = null; StringBuffer … | |
Is it possible to generate something like the following-- [code=java] public interface Reference{ // Returns a reference of the provided type (in theory) public <E> E getReference(int num); // Set the reference of the type public <E> void setReference(int num, E ref); } [/code] [code=java] public class ClassFullOfReferenceVariables implements Reference{ … | |
Re: [ICODE] void add(CTreeComponent* elem){ if(m_anzahl >= 0 && m_anzahl < 2) m_children[m_anzahl++]=elem; else std::cout << "ERROR! Element full." << std::endl; }[/ICODE] | |
Re: Find a free ebook or online tutorial to get you through the bare basics. From there, you'll most likely want to read through the chapters since they are usually presented in a technical sense and not really presented in a completely-tangible way. From there, I'd get an advanced book that … | |
Re: [QUOTE=Vallnerik25;637904]I guess what i really didn't understand was the == 0 on the end of the first line and the following line If(found) I guess what is confusing me is the assignment and test for equality all on the same line and then the following line If(found) I don't understand … | |
Re: I'm not sure if you've already implemented this class or not, but it may help you-- [url]http://www.cppreference.com/cppbitset/all.html[/url] | |
Re: I think it was your do-while loop. Maybe the program misinterpreted the return 0 and was looking for a while loop. Consider your code-- [code=c++] int main(void) { do { cout << " Copyright 2001, Welcome to the Angle Finder Program. " << endl; cout << " This program is … | |
Re: [QUOTE=sciwizeh;637588]anyone, anything, nobody can help with this?[/QUOTE] First off, if you're using the Math class' static final variables this much you should consider a static import. Secondly I'd have to see how you are calculating with your Vec2D class. I'm assuming that you are using a class you created yourself … | |
Re: First of all... please use code tags-- [*code=java*] [*/code*] without the asteriks. Secondly, Think about the conditions for winning and losing. This is a simplified version of the gambling game Craps where you don't get to choose between being on the pass line or dont pass line - you're always … | |
Re: [QUOTE=cyrinius;636731]Ahh alright, thanks for the response, makes more sense now. As for professional help i mean by someone explaining to me a few things about C++ and where i should start learning the code. I am running on windows XP, which compiler should i use to code with? i am … | |
Re: Your while statement is a recursively infinite loop. 10 will always be greater than 0, so will 9 then 8 then 7 then 6 then 5 then 4 then 3 then 2 then 1 but not zero. Because of this, the statement (while 1 > 0) keeps printing out CountDown(0) … | |
Re: [QUOTE=Waseemn;636612]Hello All, OK I am not sure if any of you here are also coming from the C++ forum, but I finished my C++ class, got an A, thanks to all your help, and now I am onto Java. I am still a beginner in both Java and C++ and … | |
I know this is a really sad question to ask, but please tell me... how and when should I ever use extern? I recall an example that Narue showed me but even if I read through the definition from MSDN.com as well as other sources, I still can't quite understand … | |
Re: [QUOTE=redZERO;636579]Is nobody replying because they have a grudge or because they really don't know?[/QUOTE] You should do whatever feels the most relational to you. If structuring physical things into classes is the way to go, go for it. | |
Re: [QUOTE=k.samdani;636390]i am the student of final year computer engineering and i need the topics of projects applicable to it... so please help me if u can..... i really thank you in advance for giving me your time and mind blowing ideas....[/QUOTE] This project may be way too easy for you … | |
I'm a complete rookie with NetBeans, and that's unfortunate because this summer our Instructor wants us to use NetBeans throughout the entire course. I'd just like to know... how do I add existing files to a project? I've tried right-clicking the project folders to see if there was some kind … | |
Re: [QUOTE=WillMcc;634790]Okay, so I'm a bit confused... here are my instructions for making a program: 1. Input each test result (i.e. a 1 or a 2). Display the message " Enter result" on the screen each time the program requests another test result. 2. Count the number of test results of … | |
Re: [QUOTE=aintlikeyou;633349]Hi guys, I need to write a program in C++ that will input data for N rectangles (0<N<5). The data for each rectangle consists of coordinates of the lower left and upper right corners, which are positive integers, less than 100. Then I need it to calculate the area of … | |
Re: This is actually a much harder task than you think. I, myself, have tried to make games. Sure some worked but when it came to upgrading them (implementing new features, etc) it became problematic because so many of my functions relied on each other. What you want to do is … | |
Re: [ICODE]if (num1 <= num2) cout << num1 << "is less than or equal to" << num/*error here*/ << endl[/ICODE] Change that to num2 and I think you won't get any more errors. | |
Re: I'm fairly certain that in order to import c++ code into another language (like Java for example), you will need a dynamic link library in order for the process to be possible. There are far more reasons for .dll files but I don't know of them yet myself. In fact, … | |
Re: Maybe you should try leaving out the parenthesis? Also, why aren't you posting the error? You should at least do that if you want people on here to help X_X | |
Re: [QUOTE=darklich13;632003]Thanks for the help I was able to get this to work. Is there a list on the Sun site that shows all the different types of exceptions?[/QUOTE] I would look up (in google) either-- java class Exception 6.0 or java throwable 6.0 --and I say 6.0 because I assume … | |
Re: [QUOTE=margierose;632428]I need to write these three functions to convert strings into integers: int dectoint( string st ); // e.g. "14" → 14 int hextoint( string st ); // e.g. "14" → 20 int bintoint( string st ); // e.g. "10" → 2 and these three functions to convert integers into … | |
Re: Note: This isn't my code, but something I found in one of the WinAPI tutorials on a forum. [code=c++] #include <windows.h> #include <cstdio> #include <iostream> #include <cstdlib> //This will clear the console. void ClearConsole() { //Get the handle to the current output buffer... HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); //This is used … | |
Re: [QUOTE=zyaday;632681]Hello, i'm using a Jpanel, I am using an image as background . On top of that i want to put buttons on it. The problem is I cannot repostion the buttons? can anyone help me here!!??[/QUOTE] There's no reason to be shy. Post your code so we can help … | |
The problem resides below - I'm trying to make a directive command that disable one constructor definition, or the other, based on the parameter of T. When I uncomment the block around the if statement, I get this error-- [ICODE]... missing binary operator before token "(" [/ICODE] --but when I … | |
Does anyone have an website they would recommend to me for learning Regex? I have tried using the Sun's tutorial on Regex as well as the Pattern and Matcher classes that use Regex but I am not quite understanding it. I'd like to use it to return the String values … | |
Re: [QUOTE=Pikachumanson;632493]I believe you got to declare what today is.[/QUOTE] He already did. I believe this is one of the reasons I like Java's enumeration-class better than C++'s enumeration type. You can't convert an int into an enum, unfortunately. | |
Re: [QUOTE=Salem;630986]If you start with say [ICODE]int tower_dmg_original[5][3] = {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15}};[/ICODE] Then later on, you could do this [code] int tower_dmg[5][3]; for ( int r = 0 ; r < 5 ; r++ ) { for ( int c = 0 ; c < 3 ; c++ ) { tower_dmg[r][c] = tower_dmg_original[r][c]; … | |
Re: [QUOTE=x_calibur;632328]Hi, I'm having a problem understanding this thing. Suppose I have a function that returns a generic value. Inside I have "try" and "catch" statements for exceptions. Now once those exceptions have been detected, what and I mean in the name of Jesus butt-hole is my function suppose to return? … | |
Re: You could create a class that handles the boundaries of your multi-dimension array. My question is this -- are you planning on having only 2 dimensions for the map or 3 in the event that you want to do some kind of map-switch? | |
Re: Changed your constructor to initialize the size in this way-- [code=c++] template <class T> list<T>::list() : size(5) //default { T *thelist = new T[list::size]; numinlist=0; newsize=5; } [/code] also changed your public static const variable to a private one-- [code=c++] private: int size; T *thelist; int numinlist; int newsize; [/code] … | |
I found an interesting question on the internet... An interviewer asked a programmer "How would you divide without using division or multiplication?" And the programmer came up with some weird bit shifting operation that did the division. Now, I'd like to make a program that does something similar, since-- int … | |
Re: Why not make a pointer to Character objects in global scope and then, based on the class the user suggest, instantiate said stats? example... [code=c++] //in global scope Character *cPtr; //Notice your constructor isn't called yet [/code] [code=c++] //when user inputs a char.. char classChoice; cin>> classChoice; switch(classChoice) { case … | |
Re: [ICODE]------ Build started: Project: AngleFinder, Configuration: Debug Win32 ------ Compiling... SteveAngle.cpp .\SteveAngle.cpp(85) : error C2296: '/' : illegal, left operand has type 'long double (__cdecl *)(const float)' .\SteveAngle.cpp(88) : error C2297: '/' : illegal, right operand has type 'long double (__cdecl *)(const float)' .\SteveAngle.cpp(119) : error C2296: '/' : illegal, … | |
Re: [QUOTE=henpecked1;631963]Is my question really that dumb that I get nearly 30 views and no replies...lol[/QUOTE] You answered your own question. | |
Re: [QUOTE=awi123;631402]Hi i just wanted to ask whether we cud use #include<string> and declare a data type called 'string' eg. string ch;? and where is "using namespace std" used?[/QUOTE] The Standard Template Directory (or Definitions... or Defined types...) is a namespace with defined C and C++ types/functions/objects. Without the "using namespace … | |
[code=c++] #include <cstdlib> #include <iostream> /** Test Class for learning template-metaprogramming */ using namespace std; template<int N> //General case for a number class ShowValues { public: static inline void show() { cout << "Start: " << N << endl; ShowValues< (N > 1) ? (N - 1): 1>::show(); cout << … | |
Re: [QUOTE=javaAddict;631458]Actually the subject that I am doing the thesis has nothing to do with programming or software. The subject is called something like: Environmental Protection. And the application will have to be a system that monitors the materials that Industries use and the wastes that they produce. Since one industry's … | |
Re: [QUOTE=ff4930;631628]I am using Maps from the STL to insert a polynomial. The Key is the exponent and the data is the coefficent. Basically I want to add/subtract and multiply them. I have the addition/subtraction down but when it comes to multiplying I have to add the exponents and multiply the … | |
Re: [QUOTE=Linda1;631622]I was doing well in this project until I was trying to do the math problem on the third class. The project is, we are supposed to create a base class of circle and create 2 derived classes The first is sector derived from circle then the segment is derived … | |
Re: [QUOTE=Ancient Dragon;631583]What I posted is also the method used to convert a string of digits to an integer if you don't want to use a standard C or C++ convertion function. Here's aother way: [icode] int c = (a << 3) + (a << 1) + b;[/icode][/QUOTE] Edit: Wrong on … | |
Re: Go to google and do the following look-ups-- Java class Double Java class Integer Java class String You'll find that you can do "parsing" much like this-- [code=Java] public class TestClass{ String myNumber = "5.2"; double value = (double)Double.parseDouble(myNumber); public static void main(String[] args) { System.out.println(new TestClass().value); } } [/code] … | |
Re: [code=java] MySuperType mytype = null; if (sub_type) { mytype = new MySubType (); //should be ok mytype.setD(4); mytype.setE(5); } else { mytype = new MySuperType (); //Most likely a compiler error } mytype.setA(1); mytype.setB(2); mytype.setC(3); [/code] When you do something like-- [code=java] Object obj = new String("Upcasted!"); [/code] --it is … | |
Re: [code=c++] CRectangle rect, rectb; rect.set_values (3,4); rectb.set_values (5,6); cout << "rect area: " << rect.area() << endl; cout << "rectb area: " << rectb.area() << endl; [/code] rect and rectb are 2 different variables that are of the same class-type. to make the code more understandable it might be better … | |
Re: Looks like you're going to make GOOD friends with-- --ASCI --Subtraction --because you can easily allow someone to enter a phrase and immediately convert the char value into uppercase. After you convert the char value to uppercase, think about the value of the char in ASCI code then do subtraction. … | |
Re: [QUOTE=Narue;630754]>So your telling me what is being displayed on my windows >screen is the output of a combination a C++ program? I'm telling you that the Windows operating system is written in a combination of C and C++. Most of the programs you run are as well. >but howwwwwwwwwwwwwwwwwww :O … |
The End.