2,712 Posted Topics

Member Avatar for XodoX

You need to create your own semi-string class, that has the operators above overloaded.

Member Avatar for mrnutty
0
91
Member Avatar for k007
Member Avatar for NeoFryBoy
Member Avatar for agaba
Member Avatar for gopi17
Member Avatar for Nathan Campos

You can use the indexes, but you can also use flags. First try to read in a file. Then check for the first quote ( " ) and if found read in the data until another quote ( " ) is found.

Member Avatar for Nathan Campos
0
3K
Member Avatar for aliaks
Member Avatar for mandofl

It alls here : [code] { switch (choice) { case 'a': case 'A': cout << "You are accelerating the car. "; cout << Accelerate(first) << endl; break; case 'b': case 'B': cout << "You have choosen to push the brake."; cout << Brake(first) << endl; break; } }while (toupper(choice) != …

Member Avatar for necrolin
0
3K
Member Avatar for sara9111

1st tooo much common sense comment : second ; [code] while (num != 0) { digit= num%=10; // you are setting digit to the last number of 10 each time this loop runs. So you end up with a 1 digit number num/=10; } [/code] To reverse the number first …

Member Avatar for mrnutty
0
129
Member Avatar for lotrsimp12345

If not defined the compiler create a : default constructor like so someClass() { }, that does nothing default destructor like so ~someClass() {}, that does nothing default assignment operator default copy constructor default address operator

Member Avatar for packrisamy
0
263
Member Avatar for D.JOHN
Member Avatar for JackDurden

vector<vector<char>> vset; //that should be an error because of the confusion of the stream operator >>. Need space between them.

Member Avatar for Ancient Dragon
0
187
Member Avatar for sdmahapatra

"(1) how to capture number of occurrences of 3 between 1 to 100? " Like this : 3,13,23,33,43,54,63,73,83,93 ?

Member Avatar for mrnutty
0
125
Member Avatar for Nathan Campos
Member Avatar for JackDurden

create a vectors of char*, then in a for loop, have char* pointing to a different vectors.

Member Avatar for daviddoria
0
120
Member Avatar for harry010

You don't need a copy constructor for that. Only if you are using dynamic memory, then you will need a copy constructor. The std::string is it self dynamic and thus you don't have to keep track of heap memory for it, the stl does it for you.

Member Avatar for harry010
0
196
Member Avatar for agaba

Here is a comment on the comments (just a few): input qty // get input from user, by creating a new variable and cin >>variable while qty > 0 //start a loop, with the conditional statement being while qty > 0 input size// ask user to input, same as step …

Member Avatar for mrnutty
0
103
Member Avatar for metdos

Just don't use Hungarian. I use Camel naming convention like so , float PlayerLife

Member Avatar for Nick Evan
0
112
Member Avatar for Jintu

1) Ask user if he wants a seat, if so then 2) Check if there are seats to fill 3) If full, then give an error, else 4) get any random seat from the list of unfilled seat array

Member Avatar for mrnutty
0
229
Member Avatar for gretty
Member Avatar for newtechie
Member Avatar for newtechie
0
180
Member Avatar for snvngrc1

to put code tags, do this : code */code , except delete * and leave no space in between.

Member Avatar for snvngrc1
0
175
Member Avatar for Koinutron

if you don't want to get the user's input as a string you can do the following (not tested) : [code] int num = 0; cout<<"Number please : "; cin >> num; while(!cin)//if input fails { cin.clear(); while(cin.get() != '\n') continue; cout<<"\nInvalid Input\n"; cout<<"Try again : "; cin >> num; …

Member Avatar for Koinutron
0
144
Member Avatar for QuantNeeds

[QUOTE=TheSamwise;939520]Simply use "srand()" at the start of the program.[/QUOTE] srand() takes an argument.

Member Avatar for mrnutty
0
807
Member Avatar for gretty

just make your own strcpy. Its not hard [code] //copy string 2 into string 1 bool stringCopy(std::string* str1, std::string* str2) { if(!str2[0]) return false; for(int i = 0; i < str2.size; i++) str1[i] = str2[i]; return true; } [/code]

Member Avatar for mrnutty
0
217
Member Avatar for invisi

On the other hand, if you use new to allocate memory for the array then you should use delete [] array, syntax. And set the other pointers associated with the array to null. Also Why are you doing this : [code] double *pd = new (a + 5) double; [/code] …

Member Avatar for mrnutty
0
906
Member Avatar for jewelpervez
Member Avatar for ithelp
0
93
Member Avatar for nuar046

If your using c++ , the command cout<<"\a"; makes a beep. You can be creative. If you are using windows, you can use beep(...), and adjust the frequency and the length of the tone. You can be creative.

Member Avatar for nuar046
0
210
Member Avatar for gretty

Create an array[SIZE]; From 'i' to 'SIZE' store 'i' into array. shuffle array; extract info from array into new one, without the same index repeating.

Member Avatar for wildgoose
0
98
Member Avatar for dalj

use seekg to set the position of the pointer to the beginning after its been read. [URL="http://www.cplusplus.com/reference/iostream/istream/seekg/"]http://www.cplusplus.com/reference/iostream/istream/seekg/[/URL]

Member Avatar for dalj
0
85
Member Avatar for DrDeadite

looking at your .txt file, you have the row and column backwards in declaring your tmp array variable.

Member Avatar for NathanOliver
0
90
Member Avatar for xAnubisx

You can encrypt the text file just as you would encrypt a string. 1) Use a string to read in all data inside the ifstream 2) Use that string to encrypt it self , for example you can use key number to encrypt like so : [code] cout<<"Enter a key …

Member Avatar for mrnutty
0
185
Member Avatar for underground111

This is how to do inheritance`: [code] class BankAccount { ... } //base class class Savings : pubilc BankAccount { ... } //saving derives from base class Checking : public BankAccount { ... } //checking derives from base class CD : public BankAccount { ...} [/code] The interface of BankAccount …

Member Avatar for mrnutty
0
1K
Member Avatar for Nathan Campos
Member Avatar for poncho4all
0
83
Member Avatar for zsady

use the std::sort algo. you will need to give it your compare function which should compare the x first then the y. example : [code] #include<iostream> #include<vector> #include<algorithm> using std::vector; using std::cout; using std::cin; using std::endl; int main() { vector< vector<float> > vec2d(2,vector<float>(2,0)); for(int i =0; i < vec2d.size(); i++) …

Member Avatar for mrnutty
0
105
Member Avatar for Sunyah

[code] //Are used to determine if certain settings are enabled/disabled //0->disabled //1->enabled "static int useRGB = 1; static int useLighting = 1; static int useFog = 0; static int useDB = 1; static int useLogo = 0; static int useQuads = 1;" //used for delay static int tick = -1; …

Member Avatar for mrnutty
0
141
Member Avatar for XodoX

I would suggest the following : 1) create an abstract base class that has the similar properties for all class 2) Derive a base class from the abstract, maybe a CarType class 3) Derive a Toyota, Honda, Lexus ... from CarType

Member Avatar for crazyboy
0
98
Member Avatar for jake43

could you explain your problem. also note that in c++ use should use cmath instead of math.h. And forget about system(...) command. They are BAD.

Member Avatar for VernonDozier
0
112
Member Avatar for Schwein
Member Avatar for Dia.A

How about you dive into it and tells us if your stuck. Make some classes, like level, character, food ... so on from there

Member Avatar for mrnutty
0
131
Member Avatar for iamsmooth

[code] ifstream iFile("text.txt"); //open file /****/ whlie(!(iFile.eof() || iFile) //while there is stuff to read { // Read content. } [/code]

Member Avatar for mrnutty
0
142
Member Avatar for ju_10_ve
Member Avatar for k007

I think your template deceleration should look something like this : [code] template<typename Type1,typename Cont = vectors<int> > class Stack { ... } [/code]

Member Avatar for k007
0
1K
Member Avatar for gauravmishra

[code] sample s; //default ctor or if is provided then it is called sample s1(s); //copy ctor is called sample s2 = s1 ; //could use both copy ctor and assignment or just one. sample s3; s3 = s2; //use the assignment operator sample s4( 5, "string") ; //use the …

Member Avatar for mrnutty
0
110
Member Avatar for jake43

Use [ code] [ /code] tags. You are missing a the while part in your do while loop. Using goto will get you killed (not really) in the c++ community.

Member Avatar for Salem
0
205
Member Avatar for cougarclaws

Here is an example : [code] int howMany = 0; cin >> howMany; for(int i = 0; i < 100; i ++) if(i % howMany == 0) cout << i; [/code]

Member Avatar for cougarclaws
0
129
Member Avatar for group256

make inner public. Then in you can access it by the scope resolution operator like so outter::inner variable name; [edit] The above assumes "outside " means from outside of the class.

Member Avatar for Sky Diploma
0
146
Member Avatar for gretty

You do know that your array is of size 0 in this code : [code] string pic_array[pic_count]; string used_pics[usedPic_count]; [/code] for your read function, use char *filename

Member Avatar for mrnutty
0
322
Member Avatar for Brandon515

when you say "put it", do you mean you copy the whole function and redefine it in main?

Member Avatar for Brandon515
0
140
Member Avatar for seanhunt

which part of overloading the << operator are you having trouble with? your prototype could be something like this : [code] std::ostream& operator<<(std::ostream& os, Real<T>& real); [/code]

Member Avatar for mrnutty
0
134

The End.