2,712 Posted Topics

Member Avatar for new2programming

You can use sdl's timer or clock, or if your on windows, Queryperformance counter. For example, here is one that uses clock(). [code] #include <iostream> #include <ctime> using namespace std; class Timer{ public: typedef clock_t TimeType; private: TimeType _clockStart; //holds the time of reference public: Timer(): _clockStart(clock()){ } TimeType getTicks()const{ …

Member Avatar for mrnutty
0
111
Member Avatar for jdpjtp910

Whe you create [I]BinaryTree<EmployeeInfo> tree;[/I], you can only insert EmployeeInfo into it. If you want to insert TreeNode into it, then create a [I] BinaryTree<BinaryTree::TreeNode> tree[/I]. I don't know why TreeNode is public. The user should not get a hold of it, since they can mess the tree up! So …

Member Avatar for jdpjtp910
0
559
Member Avatar for sksingh73

Thats because uint3_t can only hold numbers. What you want is strings. [code] #include <iostream> #include <string> using namespace std; int main(){ string input; cout << "Enter something : "; cin >> input; cout << "You entered : " << input << endl; return 0; } [/code]

Member Avatar for mrnutty
0
94
Member Avatar for techie1991

>>I want to calculate sqrt(2) to the maximum level of digits possible... You can't. Its a [URL="http://en.wikipedia.org/wiki/Square_root_of_2"]irrational number[/URL].

Member Avatar for nbaztec
0
173
Member Avatar for Swiftle

I need to see the definition of elem and sentinel before we jump to conclusion.

Member Avatar for Swiftle
0
90
Member Avatar for tendavola

my guess is that you are going out of the array bounds. Whats the size of the array?

Member Avatar for NP-complete
0
105
Member Avatar for jwelsh
Member Avatar for LevyDee
Member Avatar for Ohta

In C++ you cannot seperate the template header from its definition. So You can't have LinkedList.cpp. You need to put the definition in the same file as the header file.

Member Avatar for mrnutty
0
93
Member Avatar for timb89

You don't necessarily need a matrix class. All you need is arrays. Better yet, you should use std::vector < std::vector<float> >, as a 2d array. Adjacency matrix are fairly easy to implement with the cost of O(row^2) of space. What exactly are you having trouble with, in respect to Adjacency …

Member Avatar for mrnutty
0
306
Member Avatar for psdao1102

Change your template to this : [code] template <class T, class T2> T searchArray(T index, T2 answer, int numOfParts){ [/code]

Member Avatar for thelamb
0
83
Member Avatar for mrnutty

What do you guys think of this new daniweb design? Personally, I'm not very fond of it. The simpler the better. I just don't like the design. It needs more "flavor" or something. Idk, what do you guys think?

Member Avatar for jwenting
1
189
Member Avatar for em-kay

>> Hello FirstPerson Good morning to you to,em-kay. Now just a few points. 1) Don't use global variables like that. 2) If you don't have a choice then at least, name your variables something meaningful,so I can understand what they are. 3) To move your circle you can do 2 …

Member Avatar for em-kay
-2
2K
Member Avatar for Martje

Here is an example : [code] //Sqrt.h class Sqrt{ private: const float originalValue; const float sqrtValue; public: Sqrt(); Sqrt(float initValue); float sqrtValue(); float originalValue(); } [/code] [code] //Sqrt.cpp Sqrt::Sqrt() : originalValue(0.0f), sqrtValue(0.0f) //initializer list { } Sqrt::Sqrt(float value) : originalValue(value), sqrtValue( std::sqrt(value) ) //initializer list { /* empty */ } …

Member Avatar for mrnutty
0
85
Member Avatar for new2programming

1) Create a member variable. To hold the weapon. [code] class CPlayer{ private: Sprite weapon; //... } [/code] Now create a get and set function for the weapon : [code] void setWeapon(const Sprite& aWeapon){ weapon = aWeapon; } Weapon getWeapon()const{ return weapon; } [/code] Now you need position the weapon …

Member Avatar for new2programming
0
149
Member Avatar for bobbyg118

First, I'm not sure about this : [code] /string string message = () ; [/code] Do this instead: [code] string message; //will hold the encoded message [/code] Now your main problem is decryptLetter. This function is fairly simple. What problem are you having with this exactly?

Member Avatar for mrnutty
0
104
Member Avatar for s_sridhar
Member Avatar for Cowbox

[code] string fileName = "File"; string extension = ".txt"; for(char fileNum = '0'; fileNum <= '9'; ++fileNum){ string currentFile = fileName + string(1,fileNum) + extension; cout << currentFile << endl; } [/code]

Member Avatar for Cowbox
0
109
Member Avatar for hatzi8

Try implementing [URL="http://en.wikipedia.org/wiki/Dijkstra's_algorithm"] this [/URL].

Member Avatar for Sodabread
0
92
Member Avatar for jimJohnson

Do something like this : [code] class Polynomial{ private: std::vector<int> coeff; //the coefficiants public: void getInput(); void printPolynomial(); } [/code] its pretty much similar to yours except I use a vector instead of raw arrays. Now just implement the input and output functions.

Member Avatar for iamthwee
0
172
Member Avatar for srinu san

Maybe this will help you get started : [code] #include <stdio.h> int power(int base, int exp){ //logic goes here } int main(){ int res = power(2,10); //res = 1024 printf("%i",res); return 0; } [/code]

Member Avatar for mrnutty
-1
41
Member Avatar for helpfullProgram

[QUOTE=Ancient Dragon;1221642]Have you not heard of type casts? [icode]foo((char*)client_message[i].c_str());[/icode] or [icode]foo( const_cast<char*>(client_message[i].c_str()));[/icode] But you have to be careful about casting away the const, especially if function foo() wants to modify the contents of the string.[/QUOTE] I strongly advise against doing that. If you need to cast away a const, then …

Member Avatar for mrnutty
0
165
Member Avatar for triumphost

why do you have Sleep(...) ? and normally "if(Dict.is_open()) " is used as a error checker. There is a lot of problems with you code. Instead of listing them all, I will show you a sample program and you should contrast. [code] #include <iostream> #include <fstream> #include <string> #include <windows.h> …

Member Avatar for triumphost
0
343
Member Avatar for jelinky

If you can return an iterator, but I think that would be out of your scope. So instead return a index counter, although I am not sure how good thats gonna do you. Try something like this : [code] int floatlist::search(double x) { int index = -1; listnode *p = …

Member Avatar for jelinky
0
124
Member Avatar for leesho

What its asking you is to make a walk through table -- a step by step table where each row corresponds to each iteration of the loop. Here, I'll get you started Given this code : [code] int c = 0, sum = 0; while (sum < 8) { c++; …

Member Avatar for leesho
0
1K
Member Avatar for Martje

You are looking for std::vectors. Here is an example : [code] std::vector<int> aList(2,0); // 0 0 [size = 2] aList[1] = 1; // 0 1 [size = 2 ] aList.push_back(2); // 0 1 2 [size = 3] aList.pop_back(); // 0 1 [size = 2] [/code] You can also simulate what …

Member Avatar for VernonDozier
0
173
Member Avatar for dinesh.isuranga
Member Avatar for abhimanipal
0
82
Member Avatar for muralibobby2015

[QUOTE=muralikalpana;1219712]if condition and else condition is there....i want to display hello world. [ICODE] <? if(Condition) { echo "hello"; } else { echo "world"; } ?> [/ICODE] then my frnd asked to me what the condition should write in if condition to display "hello world".[/QUOTE] With that code its not possible. …

Member Avatar for mrnutty
0
86
Member Avatar for coding101

There are many ways you can approach this problem. I would just notepad to first sort the file and then read it in and do whatever I need to do with it. But I assume this is for learning purposes. So here is some things you can do : 1) …

Member Avatar for mrnutty
0
104
Member Avatar for Geek-Master

Here is a site to practice on, [URL="http://www.projecteuler.com"]http://www.projecteuler.com[/URL]

Member Avatar for mrnutty
0
179
Member Avatar for bsse007

I am not sure what you are asking exactly, but I'll take a stab at it, say you want to measure the time it takes for a specific part of your program to execute. To get better results, you might want to use QueryPerformanceCounter, rather than clock. But I'll show …

Member Avatar for bsse007
-1
71
Member Avatar for Sinaru

Here is a way to do it using metaprograming. That way you get the result before you even start the program. [code] #include <iostream> template<int binarySequence> struct Binary{ enum{ result = Binary<binarySequence/10>::result << 1 | binarySequence % 10 }; }; template<> struct Binary<0>{ enum{ result = 0 }; }; int …

Member Avatar for mrnutty
1
187
Member Avatar for NathanOliver

Actually, I never seen that before. Usually I just call the function w/o the return statement. I think you should omit the "return" statement on line 8 and 17, because that might confuse a reader thinking that it actually returns something.

Member Avatar for NathanOliver
0
134
Member Avatar for Roo0ond

I don't know if its right. But I would suggest to apply the euler method, or better yet, the RK4 method. Google it.

Member Avatar for mrnutty
0
141
Member Avatar for giodoli93

Here are some although googling would help you get more problems : 1) Create a program that checks if the input is odd or eve 2) Create a program that checks is a power of 2 3) Create a program that asks the user for a positive even number, if …

Member Avatar for giodoli93
0
168
Member Avatar for vihrao

>>[B] But before adding the two matrices: m1 and m2 , their destructors gets called[/B] why do you think so ?

Member Avatar for VernonDozier
0
497
Member Avatar for mrnutty

Why would they ever [URL="http://www.youtube.com/watch?v=o_psomRhMOQ"] ban this sport[/URL]. Its so easy to play. You can play with your families. You can play with friends. Hell, you can even play with a random stranger walking down the street.

Member Avatar for Lardmeister
1
67
Member Avatar for HiHe

Have a device where men can see what women are thinking, so they wont be so complicated.

Member Avatar for Lardmeister
0
147
Member Avatar for BLKelsey

Ok, here is the deal. Do you know how to do this with 1 file ? For example in 1 file, you would do this : [code] //main.cpp #include <iostream> using namespace std; float calcAverage(int inputs[], const int size); // [1] function prototype int main(){ const int NUM_OF_INPUTS = 5; …

Member Avatar for BLKelsey
0
270
Member Avatar for yongj

>>**This is my first post as I JUST joined daniweb ^^ << Welcome :) We're glad to have you apart of us. why isn't this defined ? [code]Bible::Bible(string nam, int chapt, int vers, string testa, string txt) //Initialize to any size[/code]

Member Avatar for NathanOliver
0
366
Member Avatar for Sylviodrood

First create a skeleton, maybe something like this : [code] // include needed libraries //... int toDifferentBase(int number, int originalBase, int newBase){ //code here } int main(){ //test here } [/code] Now your problem now is to implement toDifferentBase. The easiest way is to convert the input into base 10. …

Member Avatar for mrnutty
0
76
Member Avatar for bletchley

In java you do not need put a semicolon after the class deceleration. In C++ you need it. So this part : [code] #define FERMATH #ifndef FERMATH #include <iostream> #include <cmath> using namespace std; class Fermat { private: long prime p; public: Fermat(); Fermat(long num); long getNum(); bool isPrime(); }[COLOR="Red"];[/COLOR] …

Member Avatar for nezachem
0
127
Member Avatar for aleX_X

Yea, if this is what you mean : [code] #include <iostream> #include <vector> #include <string> using namespace std; typedef string Type; int main(){ std::vector<Type> msg(2,"a"); std::vector<Type>::iterator itr = msg.begin(); while(itr != msg.end()){ cout << itr->data() << endl; ++itr; } } [/code]

Member Avatar for mrnutty
0
85
Member Avatar for viziroth

What you do is use strings : [code] string data; cout << "Enter the date in MMDDYYYY format: "; cin >> date; asserCorrectFormat(data); //make sure valid format doStuff(data); [/code]

Member Avatar for iamthwee
0
105
Member Avatar for chathuD

[QUOTE=Salem;1214741]I wonder if you anticipated this kind of response? [url]http://clusty.com/search?query=virtual+function&sourceid=Mozilla-search[/url][/QUOTE] I wonder if he anticipated [URL="http://lmgtfy.com/?q=what+are+virtual+functions+in+C%2B%2B"]this[/URL] kind of response too?

Member Avatar for Salem
0
152
Member Avatar for ihatestarch

No it dosen't matter. You are a computer scientist. But for your own good I would advice you to take trig based physics. In computer graphics programmer, you will use more trig and vectors than calculus. Its good if you know calculus with addition. Anyways, its your choice, why not …

Member Avatar for Rashakil Fol
0
84
Member Avatar for Sodabread

And lets be honest, there are people that just fall under the bell curve. Sometimes, they just either 1) Don't put in the time to learn 2) Give up after getting confused 3) Or just try to pass the class, w/o a care in the world of the subject.

Member Avatar for jwenting
1
162
Member Avatar for mentos08

For this one : [code] If c >= 17 Then PictureBox17.Location = PictureBox16.Location End If If c >= 16 Then PictureBox16.Location = PictureBox15.Location End If If c >= 15 Then PictureBox15.Location = PictureBox14.Location End If If c >= 14 Then PictureBox14.Location = PictureBox13.Location End If If c >= 13 Then …

Member Avatar for mrnutty
0
116
Member Avatar for virtualsansar

Whats confusing about it? Maybe some pics will help : [code] //initial list 1->2->3->4->5->6 [/code] If I put [] around a number then thats the current pointer pointing to. So the pointer starts pointing to 1 so : [code] [1]->2->3->4->5->6 [/code] Let P1 be the current pointer, then from your …

Member Avatar for mrnutty
0
83
Member Avatar for Dewey1040

You know, this is just a suggestion so you don't have to listen. These methods : [code] double dist( Point ); void move( double, double, double ); [/code] I wouldn't make put them into the Point interface. Because I feel that they would be better of decoupled from the interface.

Member Avatar for mrnutty
0
164

The End.