527 Posted Topics
Re: Have you tried providing a .txt extension in the String name of test? [icode] // Open an input stream stream = new FileInputStream ("test.txt"); [/icode] | |
Re: Whip up some code? Give me a break X_X You should try putting in some effort, then we might help! =) | |
Re: You can take advantage of a Ternary statement by doing a comparison and returning a value based on the condition, all on the same line. [code=c++] #include <iostream> using std::cin; using std::cout; using std::endl; using std::flush; const char* result(bool); int main(){ int x = 3; int y = 4; cout … | |
Re: You should probably sift around on google, and especially wikipedia to answer those questions. [URL="http://en.wikipedia.org/wiki/Programming"]Programming[/URL] [URL="http://en.wikipedia.org/wiki/C_Programming"]C Programming Language[/URL] [URL="http://en.wikipedia.org/wiki/Forth_(programming_language)"]Forth[/URL] [URL="http://en.wikipedia.org/wiki/Compiler"]Compiler[/URL] -Alex | |
Re: First of all... when posting something like this, you should be explicit as to what type of errors you're getting. It will help for faster problem analysis and problem solving. Second, please indent your code so it's easier to follow. Lastly, it does help to tell us what compiler you're … | |
Re: [url]http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html[/url] [code=java] import java.math.BigInteger; public class TestingBigInteger{ public static void main(String... args){ BigInteger first = new BigInteger("50"); BigInteger second = new BigInteger(first.toString()); System.out.println(first); System.out.println(second); } } [/code] Have fun! =) | |
Re: SIZE might be a defined macro for something, so try to undefine it-- [code=c++] #include<iostream> using std::cout; using std::endl; #ifdef SIZE #undef SIZE #endif const SIZE= 101;//0 to 100 set containing 101 elements // ... [/code] EDIT: Scratch that. You forgot to declare a storage type for SIZE. It's const, … | |
Re: [QUOTE=afg_91320;726452][code] int array1[4], array2[4] = {3, 6, 9, 12}; array1 = array2; [/code] and this one: [code] void showValues (int nums [4][]) { for (rows = 0; rows < 4; rows++) for (cols = 0; cols < 5; cols++) // is this the line of error? cols is not declared … | |
Re: Have you tried copying your Queue into a temporary Queue, and printing the data of the temporary Queue instead? | |
Re: Here's something I managed to whip up thanks to your logic-- [code=c++] #include <iostream> #include <string> #include <vector> using std::cout; using std::cin; using std::endl; using std::flush; using std::string; using std::vector; bool isPalindrome(const string&); const char* result(bool); int main(){ vector<string> values; values.push_back("mom"); values.push_back("ffaff"); values.push_back("dad"); values.push_back("nonPalindrome"); values.push_back("blah"); values.push_back("A"); values.push_back(""); for(vector<string>::iterator i = … | |
Re: [url]http://www.sscnet.ucla.edu/geog/gessler/borland/strings.htm[/url] Also [icode] "LPCTSTR" or "LPTSTR" [/icode] Looks like 'Long Pointer (const) to String' and 'Long Pointer to String' Since CreateProcess is defined in windows.h, I'd assume that STR is referring to a char*, or c-style string. You could create your own custom method for converting an AnsiString into a … | |
Re: I thought I had the specs right until you said down-right instead of up-right in your 2nd paragraph. Maybe a picture will be helpful? Also, what are you using to graphically display your program? Is it a Console program or are you using some kind of GUI API? This question … | |
This makes me slightly curious... Why is there assembly code for the string class of C++? [code=asm] page ,132 title strlen - return the length of a null-terminated string ;*** ;strlen.asm - contains strlen() routine ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; strlen returns the … | |
Re: I love wikipedia-- [url]http://en.wikipedia.org/wiki/Genetic_algorithm[/url] --then again that may be too broad. What is your trouble exactly? Coding the Algorithm or understanding it? If you understand Java you can probably code this by understanding the concepts of the Algorithm. If you understand the Algorithm then try coding it and come back … | |
Re: Note: I'm not near a C++ compiler, but hopefully the below logic will be helpful to you. Create an interface that has two options for every subclass of its type-- [code=c++] class DoSomething{ public: DoSomething(){} virtual void option1() const = 0; virtual void option2() const = 0; }; [/code] -- … | |
Re: Programming is my passion =) I want to die typing at the keyboard trying to solve problems and improve my ability of insight =) I want my life to be absorbed by programming, because I used to write stories and also had a knack for mathematical problems. I tried putting … | |
How many of you carry your Credit card on you when you walk out the door? (It's a survey I have to do for a class %_%) I'm also going to do an offline survey, but the online survey is just as important! =) -Alex | |
Re: [QUOTE=joshmo;719319]the variable q is not declared in the class A and I dont want to declare it. Is there anyway this can be done? I tried that and it says "non-static variable cannot be referenced from a static context" If also someone could share with me what this means. Thanks … | |
Re: Templated classes denote incomplete types and you can specialize a particular case to have a completely different definition than the general case. What's the guarantee that long double isn't a specialized case in the vector class that doesn't have an inner iterator class? I'm not sure when it is resolved … | |
Re: [code=c++] template<class SomeType> void TemplateQ<SomeType>::Enqueue(SomeType newData) { if (IsFull()) throw FullTemplateQ(); else if(IsEmpty()) { QueueNode<SomeType>* nextQueueLocation; nextQueueLocation = new QueueNode<SomeType>; nextQueueLocation->data = newData; nextQueueLocation->nextPtr = NULL; if(rearPtr == NULL) frontPtr = nextQueueLocation; else rearPtr->nextPtr = nextQueueLocation; rearPtr = nextQueueLocation; } } [/code] I'm not quite sure how you want your … | |
Re: [QUOTE=animefun2;717932]Ive been looking for the right compiler that i can use with java applet to create an online game so does any one know the best compiler for java applet? and where i can find it in a free download from a website? or a list of compilers that i … | |
Re: [QUOTE=chococrack;718917][B][COLOR="Green"]SOLUTION:[/COLOR][/B] TWO files: myClass.h main.cpp [code=C++] // // myClass.h #ifndef MYCLASS_H_ #define MYCLASS_H_ template <class element_type> class myClass { public: myClass(); ~myClass(); }; template <class element_type> myClass<element_type>::myClass() { } template <class element_type> myClass<element_type>::~myClass() { } #endif /* MYCLASS_H_ */ [/code] [code=C++] // // main.cpp #include "myClass.h" int main() { myClass<int> … | |
Re: [QUOTE=kenji;718360]Well I read both the links and have a better idea about them. Iv updated my code as well but I get an error which basically says that it can't find the prototype or the variable being returned. [code=CPLUSPLUS] const char Account::*getData() const{ return data; } [/code][/QUOTE] Post all of … | |
Re: Warning! O_O Delete does not really delete! Delete frees dynamically-requested memory that the C++ program obtained from the OS at run-time. Delete does NOT actually delete anything! Do not use it freely, unless you really want to screw up your program or cause your OS to flag an error to … | |
Re: [QUOTE=Sci@phy;718207]Umm, your code?[/QUOTE] Exactly my thoughts. From what I understand, malloc can fail if you've run out of heap-space your program is using for dynamic allocation or if you are attempting to allocate memory to a location that is in use by another process. [icode]size=2097152[/icode] Your heap should be (by … | |
Re: [QUOTE=dmanw100;717946]In otherwords there isn't a way to easily make your own character in C++[/QUOTE] That seems like the truth! Especially since C++ is just a tool that interfaces with other systems, I suppose there's no direct way c++ itself could create a character the system would recognize! It would probably … | |
Re: [QUOTE=joshmo;717762]That is not it. I want A to be able to use a method in B..Is that possible[/QUOTE] I think Object creation might shed some light on this issue... If you create an Object of type A, A is at least of its class and additionally any other class it … | |
Re: [QUOTE=ruby T.;717028]i didn't ask anyone to do the whole thing .. wat i wanted is if anyone had sth similar to wat i need he/she cld share with me so i cld have an idea abt it ... cuz i already started working on it and i got stuck in … | |
Re: [code=java] // ... System.out.println(" Beverage Number of Votes Percentage"); System.out.println("-------------------------------------------------------------------------------------"); System.out.println(); System.out.println("Coffee "+choice1+ " "+perc1); System.out.println("Tea "+choice2+" "+perc2); System.out.println("Orange Juice "+choice3+" "+perc3); System.out.println("Lemonade "+choice4+" "+perc4); [/code] Use tabs instead of trying to space things out and match them up manually =/ | |
Re: An idea? Use JDBC to store book information then retrieve it later. Files are ok, but it might be easier to query necessary information than try to make a dozen different methods for obtaining books in certain order, or certain books period. | |
Re: It looks like you forgot to include your header file. Try adding this to the top of your script-- [code=c++] #include "templateq.h" [/code] Edit: Hmm interesting, I made the following changes and it managed to work-- [code=c++] //templateq.h #ifndef TEMPLATEQ_H #define TEMPLATEQ_H #include <iostream> #include <new> #include <cstddef> using namespace … | |
Re: Here's an example of encapsulating a 2D vector and emulating the behavior or a 2D vector through a class-- [code=c++] #include <iostream> #include <vector> #include <cmath> using std::cin; using std::cout; using std::endl; using std::vector; using std::ostream; using std::size_t; class TwoDimensional{ vector<int> dummyVec; vector< vector<int> > rowContent; public: TwoDimensional(unsigned int rowSize … | |
Re: There are several ways... The most popular way would be to save the information to a file then retrieve it later. Another popular way that isn't done unless absolutely necessary is by querying information to a database then retrieving it later. There may be a way to fool around with … | |
Re: In C++, you can declare a function, constructor, or operator to accept a type by reference and not value. For example, the declaration of the function-- [code=c++] void foo(int); [/code] --states that the function foo takes [a copy of] an integer and returns void. So the following would be legal-- … | |
Re: [code=c++] void printmovie (movies_t movie); [/code] Is a function declaration. The definition exists elsewhere in the same file. Short/Simple reason: C++ can be very linear. If you comment out the function declaration, you will get a compiler error. That is because the function printmovie is found after the definition of … | |
I've recently started studying the Unified Modeling Language. I'm currently using an exam book as a study guide, because it presents features without holding back on information-representation at all. Afterward, I will study the book made by the first 3 who started developing UML (since OOPSLA/OOSE I believe, though I … | |
Re: You may want to talk to williamhelmsworth or look up a C++ library that allows you to interface with your OS and export/import bitmaps from C++. Here's a code snippet from william that allows you to create .bmp's from C++, so I can imagine that importing would be a similar … | |
Re: I strongly recommend learning PHP (or JSP) and Oracle together. Knowing how to design a Web page and manage a database can get you MANY jobs in the IT field, especially when integrating a Database to store information sent from forms in HTML processed requests. Knowing XHTML is also a … | |
Re: [QUOTE=clutchkiller;714471][Linker error] undefined reference to `add()' Can someone explain that a little? Do i need to include my code to help you guys explain? Thanks[/QUOTE] It never hurts to include your code (provided it's not too long! O_O). Just be sure to use code tags @_@ -Alex | |
Re: AD provides a good suggestion. In fact, learning anything that is .NET compatible (C#, C++, ADO, VB, J#, etc) is advantageous. | |
Re: [QUOTE=priti_s;713601]Hi I have come across a question in a collection which says: One can add a reference of a collection to itself. Is it true or false? I read the explanation that, we can add the reference to the collection to itself, but it results in the [U][B]stack overflow of … | |
Re: It might do you some good to learn RMI from the book Head First Java or get a brief overview by reading Head First Design Patterns. Both books are good and provide more information about programming and Object Orientation than one would expect. And also, both books are funny XP | |
Re: You can't make a typedef out of an incomplete type, so the following would be illegal if NodeType is generalized-- [code=c++] typedef NodeType* NodePtr; struct NodeType { ItemType item; NodePtr next; }; [/code] -- because templates of typedefs are illegal. You would need to alter your struct to have a … | |
Re: [QUOTE=stilllearning;713564]Please put code tags around your code. Also, wouldn't it be easier to store the binary value you are computing in a string, inside your binary class ? And then just start at position starting point in the string and then scan for the next zero ?[/QUOTE] That would be … | |
Re: Bah, disregard this post >_< [code=java] public <T extends A> void doSomething(T type){ if(type instanceof [SpecialNeedClass]){ // typecast only for this type } // else if(...) // other specialized types else{ // if no other specialized type, perform basic A operations } } [/code] It would've been a good idea … | |
Re: This managed to work for me-- [code=java] import java.util.*; public class TestClass1{ static String seatLayout = null; static String fn = null; public static void main(String... args){ System.out.println(showAllSeats("1294")); } public static String showAllSeats(String flightNumber){ fn = flightNumber; // Make a set of arrays for each flight. This is only one … | |
Re: I think you will need assistance from a Regex library. Example (for unmanaged C++) [URL="http://www.boost.org/doc/libs/1_36_0/libs/regex/doc/html/boost_regex/introduction_and_overview.html"]here[/URL] | |
Re: I believe declarations and definitions are allowed outside main, but assignments are not. This example compiles fine-- [code=c++] #include <iostream> #include <ctime> #include <sstream> using std::cout; using std::cin; using std::endl; using std::ostream; using std::stringstream; ostream& operator << (ostream&, const tm&); tm mytime; // not quite safe int main(){ // tm … | |
Re: Interesting that you want to use a format specifically meant for separating individual values with commas, but need to retain information with commas inside it. A good way of doing this would be to make your own tokenizer and only parse information when a stack is empty. When you encounter … | |
I tried implementing a template Array-class that allows initial size of global arrays to be known at compile time, specified by the user. When I specify a class of type <1, 1> size, the file compiles fine. However, when I specify a class of any other numeric type, in either … |
The End.