NathanOliver 429 Veteran Poster Featured Poster

Yeah and?

NathanOliver 429 Veteran Poster Featured Poster

It is displaying zero because you never pass a value to balance. You have to make a constructor in your child class that will take an int and pass it to the constructor of the parent class. Just because you create an object of a derived class doesn’t mean it will get the values of the base class you declared first.

NathanOliver 429 Veteran Poster Featured Poster

is line 51 displaying 0?

NathanOliver 429 Veteran Poster Featured Poster

What kinda of file processing do you need to do? You might want to check This out.

NathanOliver 429 Veteran Poster Featured Poster

You are not reseting count anywhere. After line 16 put count = 0; and see what happenes.

NathanOliver 429 Veteran Poster Featured Poster

I think I'll stick with the use of c_str() for the time being. Ill wait till c++0x becomes more widespread.

NathanOliver 429 Veteran Poster Featured Poster

Glad to help.

NathanOliver 429 Veteran Poster Featured Poster

I think the issue is comming from how you are sizing the vector. I think you should use this to define the size of the vector in your constructors.

grid.resize(rows);
for (int i = 0; i < rows; i++)
{
    grid[i].resize(cols);
}
NathanOliver 429 Veteran Poster Featured Poster

I have not used dev c++ but I know that in MSVC++ you have to add all of the files that you want compiled into the application into the project.

NathanOliver 429 Veteran Poster Featured Poster

What compiler/IDE are you using? Do you include the files when they are seperate into your project?

NathanOliver 429 Veteran Poster Featured Poster

What do you mean by in the same file? Is all of this code in one file or is it seperate files and they are all in the same project?

NathanOliver 429 Veteran Poster Featured Poster

Are you trying to remove the .cpp file from your project?

NathanOliver 429 Veteran Poster Featured Poster

What seams to be the problem?

NathanOliver 429 Veteran Poster Featured Poster

modify is a char * not a string therefore it does not have rbegin() or rend() member function. Do you have to work with a char * or can you use a string? If you have to use a char * then you need to know the legnth of the string and then you can use a for loop to loop from the back of the string to 0. If you can use a string than you can use a reverse iterator.

NathanOliver 429 Veteran Poster Featured Poster

This is the code from the post I linked to.

#include <iostream>
using namespace std;

int main()
{
    int n = 10, inpt;

    for( int i = 0; i < n; i++ )
        cin >> inpt;

    for( int i = 0; i < n; i++ )
        cout << i << endl;

    return 0;
}

What this does is that it reads in the n number of integers. Then it displays to the console integers in the range 0 -> n-1. The problem says "there are no duplicates in the input and every number to be read is a non-negative value that is less than n's value.". Since there are no duplicates and all numbers are less than n all you need to do is display 0 to n-1.

NathanOliver 429 Veteran Poster Featured Poster

This was alread answered here. It is a trick question.

NathanOliver 429 Veteran Poster Featured Poster

I think you need to change line 15 to

if ( i < 4 && myArray[i] == myArray[i+1])

The way you have it now the last time you go through the loop you are going past the end of the array and it will cause undefined behavior.

NathanOliver 429 Veteran Poster Featured Poster

When you say it just stops does it lock up or does it display the value of b?

NathanOliver 429 Veteran Poster Featured Poster

Did you change the font of the console?

NathanOliver 429 Veteran Poster Featured Poster

You have to pass num by reference if you want it to hold the data between the functions. The way you are doing it now is passing by value. Here is a little example of the difference.

#include <iostream>

using namespace std;

void PassRef(int & num)
{
    num += 5;
}

void PassValue(int num)
{
    num += 5;
}

int main()
{
    int number = 10;
    cout << "before PassRef() number = " << number << endl;
    PassRef(number);
    cout << "after PassRef() number = " << number << endl;

    number = 10;
    cout << "before PassValue() number = " << number << endl;
    PassValue(number);
    cout << "after PassValue() number = " << number << endl;
    cin.get();
    return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

Your loop should look like this

for(int i=0; i < 50; i++)
{
    infile >> list[i];
    cout << list[num];
}

You also dont need to put it in a while loop if you know you are only going to read 50 records. If you dont know how many records you need to read than you wan use a while loop like this.

int i = 0;
while(infile >> list[i])
{
    cout << list[i];
    i++;
}
NathanOliver 429 Veteran Poster Featured Poster

You say Heading is a QString. Why to you have the () after it? Is it a function that returns a QString? What happens if you do QString = theArray[10].Heading()?

NathanOliver 429 Veteran Poster Featured Poster

Have you checked output_file to see if it is opening the file. ou can put this in your code after you open the file to make sure it is really opening the file.

if(output_file.fail())
    cout << "The file could not be opened!\n";
NathanOliver 429 Veteran Poster Featured Poster

@AD strEmployeeCategor is an STL string not a char[]. I think the issue he is having is that he is trying to compare floats and he has one of those .00000000000001's hanging around.

NathanOliver 429 Veteran Poster Featured Poster

It is a default parameter. If you do not send anything then it will default to zero but if you pass a value it will get the value passed. To pass the value you would need to have a child constructor like this.

Child(int n) : Parent(n)
{
    cout << num;
}
NathanOliver 429 Veteran Poster Featured Poster

well you need to use a loop and go from the next odd number greater than what you entered untill you find a number that is prime.

bool prime = false;
while(!prime)
{
    // check if number is prime
    // if number is prime set prime to true
    // increment number to check
}
NathanOliver 429 Veteran Poster Featured Poster

So what is your problem? From what I can see you dont define count in your strlength function. As far as I can remeber strings from the string type are not terminated with a '\0'. You can you the size() function to find the legnth of the string. You would do that by nameOfString.size().

NathanOliver 429 Veteran Poster Featured Poster

What is the code that you have right now?

NathanOliver 429 Veteran Poster Featured Poster

you need to move main to after the class. line 10 you are missing a , between the ostream& and the trashcan&. For your forth error lines 25 and 28 do not match. Your fifth error is that you dont have printCan in you class decleration. That goes for that last error as well

NathanOliver 429 Veteran Poster Featured Poster

What is the trouble you are having?

NathanOliver 429 Veteran Poster Featured Poster

The bigest you can get with and int is a long long. You can get a large number library that has no restrictions except for the amount of ram you have in your system. GMP should be able to help you out if you need anything larger than 9,223,372,036,854,775,807 as an int type

NathanOliver 429 Veteran Poster Featured Poster

try this

    if(test.find("open") != string::npos && test.find("door") != string::npos)
NathanOliver 429 Veteran Poster Featured Poster

The error you are getting is saying that it can’t find an operator << that will take a vector. The vector class does not have built in stream operators so if you want to pass a vector to << than you need to write your own function to do that.

sabrimev commented: You are saying I should oveload << operator? +0
NathanOliver 429 Veteran Poster Featured Poster

In you code you have this section now inside the second while loop.

if (order == ASCENDING) 
    if (*(j->next) < *(min->next)) 
        min = j;
else 
    if (*(j->next) > *(min->next)) 
        min = j;

You Would think that since the else is lined up with the first if that is what it is the else for but it is not. It is being treated as the else for the second if statement. This should get it working.

if (order == ASCENDING)
{
    if (*(j->next) < *(min->next)) 
        min = j;
}
else 
{
    if (*(j->next) > *(min->next)) 
        min = j;
}
NathanOliver 429 Veteran Poster Featured Poster

userInput was just a variable name i used. In your case you would want to use test instead of userInput

if(test.find("open") && test.find("door"))
NathanOliver 429 Veteran Poster Featured Poster

You are using a long int which has a max value of 2,147,483,647 so if you give it 5,744,074,063 it is going to wrap around. you can try using a long long which is 64 bits with a max value of 9,223,372,036,854,775,807

NathanOliver 429 Veteran Poster Featured Poster

Well you can see if the line from the user contains the words open and door. Something like this

if(userInput.find("open") && userInput.find("door"))
    // open door

You can also get a little more complicated and make sure you find open before the word door.

NathanOliver 429 Veteran Poster Featured Poster

Line 8 should be i = head. Line 9 should be while(i->next != NULL). Line 23 should be i = i->next

NathanOliver 429 Veteran Poster Featured Poster

Line 8 needs to match the first par of your for loop. The codition of the while loop needs to match the condidtion of the while loop. The very last line of the while loop needs to match the last part of the for loop. In you case you need to switch lines 20 and 21

NathanOliver 429 Veteran Poster Featured Poster

You can right your own pow function like this

int power(int base, int exponent)
{
    int result = base;
    for (int i = 1; i < exponent; i++)
    {
        result *= base;
    }
    return result;
}
NathanOliver 429 Veteran Poster Featured Poster

I believe line 11 should be p = p->link and you can get rid of lines 4,5 and 12.

NathanOliver 429 Veteran Poster Featured Poster

This is your first erorr: SalariedEmployee(string name, double salary) : Employee(name), salary(a_salary){}. As you can see salary and a_salary are not the same. You need to change one of them to match the other. I already cover the second error in my first post.

NathanOliver 429 Veteran Poster Featured Poster

You need to pass the salary on line 195 to the SalariedEmployee constructor

NathanOliver 429 Veteran Poster Featured Poster

Well you need to write a sort fuinction that will take an int array and sort in asscending order. You will need to repet this for decimal types and char types. Then you have to write the same sort function but change them from asecending to decending order. This will cover most of your requierments since you will overload the functions for the different types.

NathanOliver 429 Veteran Poster Featured Poster

Well you can kinda unwind the loop and make it look like this

max = score1;
if(score2 > max)
    max = score2;
if(score3 > max)
    max = score2;
if(score4 > max)
    max = score4;
if(score5 > max)
    max = score5;
if(score6 > max)
    max = score6;

I'm not sure if it any more efficient than what you have but it seems to need fewer comparisons

NathanOliver 429 Veteran Poster Featured Poster

You can use a loop but you need to store your scores in an array

NathanOliver 429 Veteran Poster Featured Poster

@ Despairy Use of global variables is slightly discouraged. They can muddle up the names in the file they belong to and can make it hard to find where things are used and declared. Its better to pass arguments to functions than have global variables sitting around and having the functions use them.

NathanOliver 429 Veteran Poster Featured Poster

As you have with your first example you declared 2 Window pointers and made one a Window and one a CommandButton. In your second example you had to have a Window and a CommandButton pointer. So having virtuall functions allow you to cast a derived object to the base and still have the function of the derived class called. This is convient because now you can have an a array of Window pointers and and as long as the class is dervied from Window you can add it to the array. then going throught the array you can call one function and will get the right one called.

NathanOliver 429 Veteran Poster Featured Poster
int * Foo()
{
   int * returnValues = new int[what ever size array you want here]
   // do stuff
   return returnValues;
}

// in main
int * getReturnValues = Foo();
NathanOliver 429 Veteran Poster Featured Poster

Technicly 1 is not prime so all you need to do is in your prime function check to see if it was passed 1 and if it was just exit the function.