NathanOliver 429 Veteran Poster Featured Poster
B& operator=(const B& b)            // Copy Assignment
{
    if (&b != this) // you should always do this so you dont do a self assignment
    {
        A::operator=(b) // call A copy assignment
        i2=b.i2;
    }
    return *this;
}
NathanOliver 429 Veteran Poster Featured Poster

I dont think so. Maybe you should read the Rules.

NathanOliver 429 Veteran Poster Featured Poster

So what seams to be your problem? We do not give answers here but we do offer assistance.

NathanOliver 429 Veteran Poster Featured Poster

Isn't that question for you to solve? We will help you hear, not give you the answers.

NathanOliver 429 Veteran Poster Featured Poster

Step 1: Write a problem statement for what you want to do
Step 2: Write an outline, if it is complex
Step 3: Write up a section in pseudo-code (English instructions)
Step 4: Write the section in the programing language of your choice
Step 5: Compile the program.
Step 6: Run your program and see if it makes the computer do what you wanted.
Step 7: If not, fix the program, and compile and go back to step 5. Otherwiae release / turn in your program.

NathanOliver 429 Veteran Poster Featured Poster

I would split the string up into an vector of sub strings. Reverse each sub string in the vector. Then combine them all back together. You can easily split a string with spaces by using string streams:

std::stringstream ss;
string line = "What a sunny day";
std::vector<std::string> parts;
string temp;

ss << line;  // load the stream
while (ss >> temp)  extract untill space or end
{
    parts.push_back(temp);
    temp.clear();  // erase temp to fill again
}

// now parts[0] = What, parts[1] = a, parts[2] = sunny, parts[3] = day
NathanOliver 429 Veteran Poster Featured Poster

That could be an error relating to the fact the you don't have a main() function

NathanOliver 429 Veteran Poster Featured Poster

Line 167: GenericPLayer::GenericPLayer(const string& name);. Get rid of the semicolon at the end.

Line 184: class Player
Line 189: virtual ~PLayer();
Do you notice the difference between the class name?

NathanOliver 429 Veteran Poster Featured Poster

That is because you have the declaration commented out on line 92.

void Hand::Clear()
{
    //iterate through vector , freeing all memory on the heap vector<Card*>::iterator iter = m_Cards.being(); for (iter = m_Cards.begin(); iter !=m_Cards.end(); ++iter)
    {
        delete *iter;
        *iter = 0;
    }
    //clear vector of pointers
    m_Cards.clear();
}

Should be

void Hand::Clear()
{
    //iterate through vector , freeing all memory on the heap 
    vector<Card*>::iterator iter = m_Cards.being(); 
    for (iter = m_Cards.begin(); iter !=m_Cards.end(); ++iter)
    {
        delete *iter;
        *iter = 0;
    }
    //clear vector of pointers
    m_Cards.clear();
}
NathanOliver 429 Veteran Poster Featured Poster

Its just Microsoft being Microsoft. I am going to spin up a linux distro on my machine at home sometime soon and see if I can get rid of Bill Gates influence at home.

NathanOliver 429 Veteran Poster Featured Poster

What do you need help with? Your instructor gave you how the program should function and work. Is there a part you don't understand?

NathanOliver 429 Veteran Poster Featured Poster

This details why this can't be done. There is a hack here that you can do to get around this but it is not microsoft approved.

NathanOliver 429 Veteran Poster Featured Poster

I would use the modulo operator (%) and division for this. Modulo gives you the remainder of integer division so 100 % 10 = 0. So if 100 % 10 = 0 then you need to get rid of the rightmost 0 by division. Divsion by 10 will do that. Put it together and you need a while loop that checks if the value modulo 10 is 0 and then in the body of the loop you need to trim off that zero using division by 10.

NathanOliver 429 Veteran Poster Featured Poster

You have ab extra } on line 197. get rid of that and it should compile. No sure if your code is exactly right though. it looks weird that you have 3 if(!found) statements.

NathanOliver 429 Veteran Poster Featured Poster

Step 1: Write a problem statement for what you want to do
Step 2: Write an outline, if it is complex
Step 3: Write up a section in pseudo-code (English instructions)
Step 4: Write the section in the programing language of your choice
Step 5: Compile the program.
Step 6: Run your program and see if it makes the computer do what you wanted.
Step 7: If not, fix the program, and compile and go back to step 5. Otherwiae release / turn in your program.

NathanOliver 429 Veteran Poster Featured Poster

Okay go ahead and get coding. Is there a part you dont understand?

NathanOliver 429 Veteran Poster Featured Poster

Did a recent change happen to the spell checker? I could be wrong but now it is spell checking things inside code tags to where before I can't remember it doing that. I also had a weird result when spell checking with a web link where it changed the web address in the preview to something like daniweb spellcheck passer. The link was correct when posting though.

NathanOliver 429 Veteran Poster Featured Poster

More then likely it is not. Post the code using the #ifndef that does not work.

NathanOliver 429 Veteran Poster Featured Poster

Post the code you have.

NathanOliver 429 Veteran Poster Featured Poster

What problem are you actually having? Do you know how to find if two circles on a plane intersect? I don't think you will find anyone on here that is willing to do your work for you. To find out if two circles intersect you can see if the difference of their radii is less then or equal to the distance the circles are apart. That would be:

R1 - R0 <= sqrt((x1-x0)^2 + (y1-y0)^2) 

You could also square both side to not have a call to sqrt and it would be:

(R1-R0)^2 <= (x1-x0)^2 + (y1-y0)^2
NathanOliver 429 Veteran Poster Featured Poster

Oh. Oops. You could also do this using a string stream:

string leftoverInput
string temp;
stringstream ss;
while(getline(cin, temp))
    ss << temp;
leftoverInput = ss.str();

I am not sure if it would be any faster but you could also use just a couple strings:

string leftoverInput
string temp;
while(getline(cin, temp))
    leftoverInput += temp;
    // or
    leftoverInput.append(temp);
NathanOliver 429 Veteran Poster Featured Poster

You need to actually change input every loop. You can do that by using input /= 2; after line 17.

NathanOliver 429 Veteran Poster Featured Poster

You also need to get rid of line 23. that will force you out of the loop on the first iteration which is not what you want.

NathanOliver 429 Veteran Poster Featured Poster

If you really want to clear out the input buffer then you should use Narue's code. Calling std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n'); should work almost always but as Narue mentions in her post there a a couple edge cases that will break it.

NathanOliver 429 Veteran Poster Featured Poster

Well a queue is a FIFO data structure. In order to sort it you need to to find the smallest part by popping the front and checking it against a min variable. Then if it is not smaller push it back on the back of the queue. Do that until you go all the way through the queue and you should have the smallest element in the queue. add it to the builder queue and remove it from the unsorted queue. Then you go through the queue again and find the smallest element. Then you add that to the builder queue and remove it from the unsorted queue. Keep doing that until the starting queue is empty.

NathanOliver 429 Veteran Poster Featured Poster

Show we what code you used for that. Did you remove the line inFile >> number; from inside the while lop as that will cause a double read.

NathanOliver 429 Veteran Poster Featured Poster

Do you know how to output in C? Do you know to cast to different types in C?

NathanOliver 429 Veteran Poster Featured Poster

Give this article a read.

NathanOliver 429 Veteran Poster Featured Poster
CTime_24& CTime_24::operator+=(int seconds)
{
    m_Seconds += seconds;
    m_Minutes += this->m_Seconds / 60;
    m_Seconds %= 60;
    m_Hours += this->m_Minutes / 60;
    m_Minutes %= 60;
    m_Hours %= 24;
    return *this;
}

////+= operator ///
CTime_24 CTime_24:: perator+=(CTime_24& sTime)
{
    m_Seconds = m_Seconds + sTime.m_Seconds;
    m_Minutes = m_Minutes + sTime.m_Minutes + m_Seconds / 60;
    m_Seconds %= 60;
    m_Hours = m_Hours + sTime.m_Hours + m_Minutes / 60;
    m_Minutes %= 60;
    m_Hours %= 24;
    return *this;

}
NathanOliver 429 Veteran Poster Featured Poster

while (!inFile.eof()) is never the way you want to read from the file. When reading the last line of the file the EOF flag does not get sent until it tries to read past the last line so while (!inFile.eof()) will actually read all lines in the file plus one. You should use a read operation to control the loop since once the read fails it stops the loop. Since you use inFile >> number; in your while loop you can rewrite it as the following:

while (inFile >> number)
{
    total += number;
    count++;
    cout << number << endl;
}
NathanOliver 429 Veteran Poster Featured Poster

This could be done very simply with the strings [] operator:

int main()
{
    std::string line;
    std::cout << "Please enter you string: ";
    getline(std::cin, line);

    // loop through each letter and add 2 to it while displayng it
    for(std::string::size_type i = 0; i < line.size(); ++i)
    {
        std::cout << char(line[i] + 2);
    }

    std::cin.get(); // use this to pause system.  not system("pause")
    return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

Did you copy this code from somewhere? I have a hard time believing that you could produce this code and not know how to generate random numbers.

NathanOliver 429 Veteran Poster Featured Poster

What are you supposed to do with the data when you get it? What part of reading in from the file is giving you a problem?

NathanOliver 429 Veteran Poster Featured Poster

@ Fosterzone An array isn't just for int's. All an array is is a group of elements that all have the same type. each element is differentiated by a unique identifier (index). You can think of an array as a cubbyhole. The array has a number of spots equal to the size of the array and the size of each hole is big enough to store the data type that the array is declared for.

NathanOliver 429 Veteran Poster Featured Poster

Is there anything in particular you want to know. I don't think anyone on here is just going to tutor you in C++.

NathanOliver 429 Veteran Poster Featured Poster

What are you trying to do with this? From what I know about lambda's [this]()->x means: function that captures the this pointer and returns x and has no function body. It would be helpfull to see the use case for your macro. Also are you sure you want to use a macro? Could this be something that's solved with a template? Remember macros are evil.

NathanOliver 429 Veteran Poster Featured Poster

if your compiler is saying the code from the STL is causing the sigsegv ignore that. 99.99% of the time it is your code that is causing the issue. Can you post the code that you have the deals with the arrays?

NathanOliver 429 Veteran Poster Featured Poster

This is a typical symptom that you are trashing the memory. If removing a variable fixes a sigsev that normally means you are trying to access an array out of bounds. Are you doing any dynamic memory allocation? Do you have an array of videos somewhere in your code?

NathanOliver 429 Veteran Poster Featured Poster

I think you missed the most important part of the assignment.

You are required to write a program...

NathanOliver 429 Veteran Poster Featured Poster

First you have to write classes that will define every object that is represented in that scene. Once you have that then you need to use those classes in your code to create each object. Just from looking at the picture you are going to need at least 10 different classes. There are kids and women in the scene so you would need a person class. There are animals so you would probably want a base animal class and then one class for each type of animal that inherits from animal. You will need a Property class that will hold everything that is in the property. There a few other things you need but I'll leave that to you. It wont be very complicated but it will be a decent amount of code.

NathanOliver 429 Veteran Poster Featured Poster

What is the type of category_name

NathanOliver 429 Veteran Poster Featured Poster

What is the problem you are having? Taking some else's broken code and trying to use might not be the best approach.

NathanOliver 429 Veteran Poster Featured Poster

Thank you Mike. As always I appreciate your contributions.

NathanOliver 429 Veteran Poster Featured Poster

Well when you make a wrapper class you are basically redoing the public facing side of the class. Lets say the class has a bunch of everloads that you never want to be seen. What your wrapper class would provide is the one function you want and it would forward it on to the actual class.

clas Complexe
{
public:
    int foo(int);
    int foo(short);
    int foo(long);
    int foo(long long);
    //...
};

class Wrapper
{
private:
    Complexe hiddenClass
public:
    // this is the only one I want to see
    int foo(int someInt)
    {
        return hiddenClass.foo(someInt);
    }
    //...
};

So you can see from aboce we will still use the complexe class but wrapper will provided a more trimmed down interface. You can also do this for blocks of function to give them a more object look and feel.

NathanOliver 429 Veteran Poster Featured Poster

Can I ask what char *strerror(num) int num; means? I have never seen a function declared like that before.

NathanOliver 429 Veteran Poster Featured Poster

Someone probably can but you need to start your own thread and explain show the code that you have and what part you are having trouble with.

NathanOliver 429 Veteran Poster Featured Poster

<cmath> is the c standard math library. You would need to included it when you want to use the standard math function. Here is a list of all the functions contained in <cmath>. The header has also been updated with c++ functions parameters/returns that are not available in c.

NathanOliver 429 Veteran Poster Featured Poster

When you do:

cout << "enter some information: ";
cin >> choice;

And the users enters 1 then what actually goes into the stream is "1\n" and cin >> choice will read until it hits whitespace (space, tab, newline) and it leaves the whitespace in place. So after you do cin >> choice the stream will contain "\n". This becomes a problem if you use getline(). getline() function as read what is in the stream until you hit the delimeter (default is newline) and then discard the delimeter. So if the stream has "\n" you then do:

cout << "enter some information: ";
getline(cin,info);

And the user enter test then the stream becomes "\ntest\n". Calling getline() it would see the newline and stop reading leaving "test\n" in the buffer.

So if we call cin.get() after cin >> choice get() will read and throw out 1 character in the buffer. Since cin >> choice would leave the buffer with "\n" get() will consume that (eat) and getline will work properly.

JasonHippy has a better way of doing that and it is using cin.ignore(std::numeric_limits<int>::max(), '\n'); but i know get() works in this case so thats why I used it.

NathanOliver 429 Veteran Poster Featured Poster

Here is your corrected code. I commented what I changed.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;

void collegesUniversities()
{
    ifstream campuses;
    campuses.open("colleges.txt");

    vector<string> schoolVector;
    string schools;
    bool match = false;

    cout << "\nEnter the name of your college/university. ";
    // cin >> schools; <- dont use this since you are using getline
    getline(cin, schools);

    if (!campuses)
        cerr << "Error opening file. ";
    else
    {
        string temp;
        while (getline(campuses, temp, '\n'))
        {
            schoolVector.push_back(temp);
        }
    }

    for (size_t i = 0; i < schoolVector.size(); i++)
    {
        cout << schoolVector.at(i) << '\n';

        if (schoolVector[i] == schools)
            match = true;
    }

    // moved this outside the loop so it prints at the end of the list
    if (match)
        cout << "\n" << schools << " is on the list.\n ";
    else 
        cout << "\n" << schools << " isn't on the list.\n ";
    campuses.close();
}

int main()
{
    int choice;

    cout << "Welcome to my college and university search program.\n";
    cout << "\nPress any button to continue.\n ";
    system("pause>nul");

    do
    {
        cout << "\nPress 1 to enter possible colleges and universities.";
        cout << "\nPress 2 to find out how many colleges and universities";
        cout << " appear in your state.\n";
        cout << "Press 3 to find the total amount of colleges and";
        cout << " universities in our list. ";
        cout << "\nPress 4 to quit. ";
        cin >> choice;
        cin.get(); // <- added this to eat the newline left after getting the number

        if (choice …
NathanOliver 429 Veteran Poster Featured Poster

Change line 29 if(temp == schoolVector[i]) to if(schools == schoolVector[i]) since schools is what you ask the user for. temp is just what was last read from the file.