2,712 Posted Topics

Member Avatar for yasirjani

Oh so you mean in 1 location, there can be up to 3 treasures. Can you show me how are are setting up your 2d array. The size and whatnot.

Member Avatar for yasirjani
0
108
Member Avatar for Andreas5

I commented on your actual code. I comment it as I read it. [code] //Good, gaurds are good, but name them something useful like // MATRIX_H_ #ifndef GUARD_MM_info #define GUARD_MM_info #include "stdafx.h" #include <vector> #include <string> #include <iostream> #include <utility> #include <algorithm> class Matrix { public: //I like this typedef, …

Member Avatar for Andreas5
0
126
Member Avatar for ichigo_cool

First take srand( time(0) ) out of the constructor. Put srand( time(0) ) at the beginning at main. Second do this : [code] strength = (rand() % 20) + 8; dexterity = (rand() % 20) + 8; [/code] So that way they both get different values range from 8 to …

Member Avatar for mrnutty
0
240
Member Avatar for Qu4n7um

I will be glad to help, first to start out. Here are some guidlines. 1) Get a IDE, I suggest one of these, [URL="http://www.codeblocks.org/downloads"]codeblocks[/URL] or visual studio 2008. 2) Now you need to start making projects, so google online on how to make projects with either codeblocks or visual studion, …

Member Avatar for ichigo_cool
0
185
Member Avatar for jiglypop
Member Avatar for so0lid

>>Or even better: I beg to differ. Not only is that hard to read, but also harder to understand, plus it leave the user to remember to delete the object returned. @OP: I advise you to use string, but if this is for learning purposes, then you can do something …

Member Avatar for mrnutty
0
98
Member Avatar for old_jefrey

>>what would best way to approach this in order to combine these 3 functions into 1? The best way to do this is to not do it. Functions are there to help create more readability for the coder and the reader. The more the better. By trying to combine functions …

Member Avatar for mike_2000_17
0
141
Member Avatar for epicasian

Your syntax is wrong. You need to use the [URL="http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/cplr016.htm"]scope resolution operator[/URL]. So your call would look like this [i]myEngine::GeneralCore::WindowManager:: DisplayWindow()[/i]

Member Avatar for epicasian
0
109
Member Avatar for tong1

The maximum value a int can hold in java is [i] [b] 2,147,483,647 [/b] [/i] while [i] [b] 13! = 6,227,020,800. [/i] [/b] So you see that an int cannot hold 13! or higher. Its only big enough to hold 12! or less.

Member Avatar for tong1
0
1K
Member Avatar for crodriguez08

First this constructor : [code] Student::Student(){ int *gptr; gptr = new int grade[3]; } [/code] is incorrect, it has a memory leak. You already have declared a gptr in your .h file, so you can just delete [i] int *gptr [/i] thats inside the default constructor. Second I don't see …

Member Avatar for crodriguez08
0
475
Member Avatar for altf4

There are a couple of options. 1) Use std::vector< std::vector > 2) Use dynamic arrays 3) Create a static array, with big enough size, and get the limited user's input as size. And use that variable, as the max size.

Member Avatar for mrnutty
0
191
Member Avatar for aaronmk2

Example: [code] class list{ public: class Node{ }; }; list::Node n; //declare a Node object [/code]

Member Avatar for mrnutty
0
97
Member Avatar for Garrett2011

Why do you need centimeter and meter, you can just work with meter. Centi is just an extension of meter? And come to think of it, your just scaling the width and the height. It makes no sense to me, to put that in the constructor. It should go as …

Member Avatar for Garrett2011
0
2K
Member Avatar for Rickay

Just use strings. [code] std::string input; std::string pass = "file.txt"; cin >> input; if(input == pass){ /* success */ } else { /* fail */ } [/code]

Member Avatar for Ancient Dragon
0
145
Member Avatar for fpsasm

Have you converted the x and y variable into world coordinates? Does graphCalculation takes the mouse coordinate in world space? Or does it want to raw pixel points? Can you show how the graphCalculation function looks like? Can't really help without more info.

Member Avatar for fpsasm
0
131
Member Avatar for bleedi

a better solution would be to define an operator>>. For example : [code] std::istream& operator>>(istream& is, Client& c){ return is >> c.acccount >> firstName >> lastName >> balance; } //...in main somewhere Client c; while( file >> c) vectorVariable.push_back(c); [/code]

Member Avatar for mrnutty
0
256
Member Avatar for ThrasherK

wait are you supposed to sort the rows first, and if there is any collision, like 2 values are the same in the rows, then you use the columns to resolve the conflict if possible?

Member Avatar for ThrasherK
0
188
Member Avatar for Takudzwa Tizora

>>how would one define RANDOM FILES [code] string randomFile = "randomFile.txt" [/code] >> well as suggest ways of creating [code] ofstream newFile(randomFile.c_str()); [/code] >>updating them in Visual C++ "Updating" is subjective, what kind of update? If you want better answer, We need better and more specific questions.

Member Avatar for mrnutty
0
105
Member Avatar for Duplaix

>>fromBinaryToDecimal To convert from binary to decimal you use the expansion rule. For example : convert "1010" to its decimal value. To convert 1010 into a decimal value, we note the position of each bit. [code] [COLOR="Red"]3 2 1 0 [/COLOR]//position of each bit 1 0 1 0 //binary number …

Member Avatar for mrnutty
0
148
Member Avatar for PDB1982

It seems like you just wan't to ask question and not do any reasearch, i.e be lazy. Did you think google did not have an answer to this question? Google has answers to all. Here is a [URL="http://lmgtfy.com/?q=c%2B%2B+class"] answer [/URL] to your question.

Member Avatar for Knightly
0
557
Member Avatar for badprogrammer

I can have this done for you in a hour or so, but its gonna cost you $100.00 dollars, or $130.00 express.

Member Avatar for mrnutty
-1
117
Member Avatar for ssmg

Well thats what a for loop is for. Or you can use strings [code] string sent = "ILoveYouMary"; string sub = sent.substr(5); //"YouMary" [/code]

Member Avatar for ssmg
0
123
Member Avatar for emps

Instead of making things global, why not make your function take in a _aline as a parameter? For example [i] ReadConfig(const _aline* line){ /* work with line variable */ } [/i] And all you have to do is make sure that you can call ReadConfig from your file.

Member Avatar for emps
0
1K
Member Avatar for ThrasherK
Member Avatar for newbiecoder

>>What if I want the output to be ANY float rand() has a limit on the highest number it can return, specifically RAND_MAX. So if you want to output any float number you need to adjust accordingly( or use a better RNG).

Member Avatar for arkoenig
0
439
Member Avatar for +_+man

Put it into a vector, then randon shiffle it, and get the first element. Here is an example: [code] int doIt(){ declare std::vector<int> variable; while input.isgood, put input into variable. call std::random_shuffle with variable; print variable[0], a random number from the list of inputs given. } [/code]

Member Avatar for daviddoria
0
100
Member Avatar for mrnutty

Is it just me, or does it seems that people posting here are getting dumber and dumber? Dang if its this hard for you then, go work at McDonalds or something.

Member Avatar for mrnutty
-1
107
Member Avatar for Aia

Oh wow. This is so shocking. At least, now he's in a safe place with nothing but happiness. Dave, if your listening, say hi to Jesus for me.

Member Avatar for sureronald
9
625
Member Avatar for mrnutty

Say you have a class Foo, and it contains some member variables. And in that class you have a const-correct function. Can you code some way in C++, that changes the private member variable, inside the const-correct function. For example : [code] class Foo{ int num; public: void doIt()const{ num …

Member Avatar for Fbody
0
96
Member Avatar for XxPKMNxX

Make a simple timer class to simplify stuff. For example : [code] #include <iostream> #include <ctime> using namespace std; class ClockTimer{ public: typedef time_t TimeType; private: TimeType startTime; public: ClockTimer(): startTime(clock()){ } TimeType elapsed(){ return clock() - startTime; } TimeType elapsedInSec(){ return TimeType(elapsed()/float(CLOCKS_PER_SEC)); } void start(){ startTime = clock(); } …

Member Avatar for XxPKMNxX
0
198
Member Avatar for crapgarden

You need to pass it an iterator!!!!!!!! Even you said it. But when you use the operator[], on a vector you are de-referencing it! Which means you access the elements stored, in your case its a string. So basically, now you are left with trying to turn a string into …

Member Avatar for mike_2000_17
1
147
Member Avatar for smoothe19

Think about it first. If you have a string like so : [i]string sentence = "This is a sentence that needs to be splitted";[/i] how would you go ahead and get word by word? How would you start? Use this as an exercise.

Member Avatar for Andreas5
0
138
Member Avatar for gahhon

I wrote this DateClass some time ago, see if you find a use for it. Study carefully and you might find what you wanted. [code] #pragma once #ifndef DATE_TIME_H_ #define DATE_TIME_H_ #include <ctime> #include <string> #include "CommonFunction.h" using std::string; typedef unsigned long ulong; struct DateInfo{ ulong seconds;//current seconds ulong minutes;//current …

Member Avatar for gahhon
0
4K
Member Avatar for Lusiphur

Here are some, [URL="http://docs.sun.com/source/806-3568/ncg_goldberg.html"]What Every Computer Scientist Should Know About Floating-Point Arithmetic[/URL]. [URL="http://programmingexamples.net/index.php?title=Main_Page"]Programming Examples[/URL] [URL="http://ootips.org/yonat/4dev/smart-pointers.html"]Smart Pointers[/URL]

Member Avatar for mike_2000_17
0
372
Member Avatar for maplax

The right way depends on the situation. But I would suggest to do something like this: [code] #include <vector> struct Book{ string _name; string _author; float _price; //...more info Book(const string& name,const string& author, float price) : _name(name), _author(author), _price(price){} }; int main(){ std::vector<Book> listOfBooks; listOfBooks.push_back( Book("America","Obama Hussian", 59.95); //add …

Member Avatar for mrnutty
0
110
Member Avatar for crapgarden

>>[B]*array[4]; // pointer to 5th content of array.[/B] The above is correct only if array is declared as [i] DataType*** array [/i], because you deference it twice. If you declare array as [i] DataType array[] [/i] then [i]*array[4][/i] is invalid syntax, because you are using the dereferencing operator on a …

Member Avatar for Ancient Dragon
0
237
Member Avatar for crapgarden

For #2, iterators are just classes. They have certain operation defined for them. For example they define the deference operator, which is why you can deference them. Similarly, the library does not define the operator << for the iterators, thus it is a compiler error. For #3, "selection < gameLibrary.end())" …

Member Avatar for mrnutty
0
338
Member Avatar for Kanoisa

You should be fine, but you can always separate your logic : [code] if(condition1 && condition2){ /*logic here */ } if(condition1){ if(condition2){ /* logic here */ } } [/code] But,you don't even need isOccupied variable, if you default initialize player to null, in the class, then you can just check …

Member Avatar for Kanoisa
0
118
Member Avatar for Rickay

[QUOTE=Rickay;1279718]Thank you, I actually figured that out about a minute after posting that hehe... but another question along those same lines if thats okay. How can I use an if statement to decide whether the input is a character or an integer? [CODE]if(x == char) //code here... if(x == int) …

Member Avatar for jonsca
0
135
Member Avatar for Hektzu

A int is not going to hold a number that big. Use [i] __int64 [/i] instead. [code] __int64 n = atoi("11111111111111"); [/code]

Member Avatar for Hektzu
0
217
Member Avatar for mrnutty

From project euler : [code] By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. [COLOR="Red"]3[/COLOR] [COLOR="red"]7[/COLOR] 4 2 [COLOR="red"]4[/COLOR] 6 8 5 [COLOR="red"]9[/COLOR] 3 That is, 3 + 7 + 4 + …

Member Avatar for iamthwee
0
138
Member Avatar for mrnutty

Look [URL="http://www.spoj.pl/problems/ADDREV/"]here[/URL] for a complete description of the problem. Your code should follow the coding standards, good names, spacing, easy on the eyes...etc. Make sure you handle all test case and boundaries. Good Luck, and happy coding. Although this is a C++ forum, it would be nice to see some …

Member Avatar for iamthwee
0
343
Member Avatar for Andreas5
Member Avatar for yatender123

Yes, I charge by the hour. The rate depends on the project. Can you supply more info.

Member Avatar for Ancient Dragon
-1
37
Member Avatar for +_+man

I think you are looking for random number generator. Here is an example : [code] #include <iostream> #include <ctime> int main(){ srand(time(0)); //seed random number generator for(int i = 0; i < 5; i++){ for(int j = 0; j < 5; ++j){ int randomNumber = rand(); //use rand() function to …

Member Avatar for +_+man
-1
73
Member Avatar for YasukiMai

Here is what I got : [code] #include <iostream> using namespace std; template<typename T> void printN(T arg, int n){ while(n--)cout << arg; } int main(){ const int ROW = 9; for(int r = 0; r != ROW; ++r){ printN(ROW, r); printN('*',ROW - r); cout << endl; } return 0; } …

Member Avatar for finito
0
90
Member Avatar for coolblazer

[B]>>fstream FILE[/B] Change the name from FILE to something else like file, because you have a name clash with the standard FILE defined in cstdlib header file.

Member Avatar for coolblazer
0
174
Member Avatar for crapgarden

>>Strings used to be an array of char in C-style coding. Now they're objects in C++. Forget about what it used to be is C. std::string is a class. An instance of a class is called an object, so [i] std::string name [/i], here name is an object, because it …

Member Avatar for crapgarden
0
231
Member Avatar for larkson

The best thing to use is std::map here. That will give you very good performance. Here is an example : [code] #include <iostream> #include <map> #include <string> using namespace std; typedef pair<string,int> NamePair; int main(){ std::map<string,int> listOfNames; listOfNames.insert( NamePair("jeff",0) ); listOfNames.insert( NamePair("Don",1) ); listOfNames.insert( NamePair("Calvin",2) ); //or read from a …

Member Avatar for mrnutty
0
187
Member Avatar for crapgarden

>>string word2("Over"); >>string word3(3, '!'); The string class, has the proper constructor that allows those syntax. So it calls the string class constructor. Other that that, i'm not so sure about your question, maybe its because i'm tired.

Member Avatar for crapgarden
0
177

The End.