Labdabeta 182 Posting Pro in Training Featured Poster

My guess is that it is reading a/b as one thing. Have you tried entering a / b instead? Also note that you do integer division, so if a is less than b you will get zero as your value.

Labdabeta 182 Posting Pro in Training Featured Poster

This link (and the downloadable example) helped me understand rotation in OpenGL far better.

Labdabeta 182 Posting Pro in Training Featured Poster

I don't think you ever made a PLUCode variable. I could be wrong, but it's definition is definately not easy to find.

Labdabeta 182 Posting Pro in Training Featured Poster

First of all you made neither of the changes I suggested, so even after you stop getting errors your code will not work. Second note that you named the function getChangeStock, not changeStock so that is one of your errors.

Labdabeta 182 Posting Pro in Training Featured Poster

That was helpful! I noticed a few things. One, on line 28 I do not think you need to open the file as I think the constructor will have done that for you. The main problem though I believe lies in line 100. You have this inFile and are intending to read from it, but it appears that you accidentally read from cin instead. Change cin>>plu.... to inFile>>plu...

Labdabeta 182 Posting Pro in Training Featured Poster

You have a fair bit of code there... could you use [ CODE ] tags to get it highlighted for us?

Labdabeta 182 Posting Pro in Training Featured Poster

I am not certain, but I do not think that if (opr='+',...) works. I would suggest trying:

if (opr='+'||opr='-'||...)
Labdabeta 182 Posting Pro in Training Featured Poster

I think that the best way to do this is probably through another function definition. Basically you can use your function, but also declare one like this:

DOSTUFF& Insert()
{
    //whatever you do with no parameters
}

I am not sure if it would work, but I would think that the compiler would automatically match Insert() to the void version rather than try to fit the templated version. To check the type I think you can use type_id or something like that, do some research and you should be able to find it... if not I am sure that someone else on this forum knows the answer. To restrict templates to a specific type I refer you to http://www.learncpp.com/cpp-tutorial/146-partial-template-specialization/, it is quite informative. Hope this helps!

Labdabeta 182 Posting Pro in Training Featured Poster

First of all, why make a modulus function. There is a pretty little operator for that in c++ (%). Also I would suggest avoiding infinite loops and relying on the system to stop your program. Instead use a boolean to wait for... what? I have no Idea what the goal is, the program does not make much sense (the variable names are pretty bad). For the matrix letter effect you would need some ability to seek in the console. Then you can do something like this:

class MatrixStreak;
int main()
{
     vector<MatrixStreak> streaks;
     bool continuing=true;
     while (continuing)
     {
         if (randomNumber()==0)
         {
             streaks.add(MatrixStreak();
         }
         for (int i=0; i<streaks.size(); ++i)
         {
             streaks[i].draw();
         }
         continuing=keyIsPressed(ENTER);//or whatever you want
    }
    return 0;
}
class MatrixStreak
{
    private:
    int x,y,ylimit;
    public:
    MatrixStreak()    
    {
        x=randomNumber();
        y=randomNumber();
        ylimit=y+randomNumber();
    }
    bool draw()//return false if dead
    {
        putAt(x,y++,randomCharacter());
        return (y<ylimit);
    }
};

Of course that was just pseudo-code. The necessary functions would be platform specific.

Labdabeta 182 Posting Pro in Training Featured Poster

I believe the point really lies in the comparison between the different big-O values. For example take the problem of sorting a dictionary. Taking a look at two common algorithms, insertion sort and merge sort we want to decide which one to use. Insertion sort's best case scenario is O(n) as opposed to O(nlogn) of merge sort. For large arrays then Insertion sort will be faster in the best case scenario. But looking at worst case we get insertion sort with O(n*n) and merge sort with O(nlogn) now we see that for large arrays merge will be better in the worst case. The question is which to use? If for example the user is going to enter each element individually, an insertion sort will be better because at any step the array will already be mostly sorted, but if we load the dictionary from a file we get all the data at once and then, since the data could be completely unsorted, we would want a merge sort. Basically big-O notation not only helps to bench-mark an algorithm for bragging rights, but also gives you information on when it is most appropriate.

Labdabeta 182 Posting Pro in Training Featured Poster

Think about it logically. You have O(N) executions of loop N and N executions of loop M. I would think that the complexity then would be O((N^2)M) of course I do not really know much about big-O notation (I just self-taught myself it) does anybody know if O((N^2)M) is right, or any good resources for learning big-O notation?

Labdabeta 182 Posting Pro in Training Featured Poster

My guess is that your HowMuchDataInFile function needs to return the value - 1 because of the name of the city occupying the first line of the file. IE: return howmuch-1;

Labdabeta 182 Posting Pro in Training Featured Poster

Well your code would be easier to understand in english. I can sort of assume what each function and/or variable will do, but it is hard in lithuanian.

Labdabeta 182 Posting Pro in Training Featured Poster

I am not entirely certain, but maybe the problem has to do with the unusual characters? You may need to store them in an int and not a char to allow for long unicodes. It may be easier if you translate the code into english.

Labdabeta 182 Posting Pro in Training Featured Poster

You would need a boolean value to store the state of the primality of the number. A simpler approach is to use a function, which hopefully you have learned. This is what I usually use for a primality check:

bool isPrime(int x)//checks if x is a prime number
{
    for (int i=2; i*i<x; i++)//loop from 2 to SQRT(X)
    {
        if (x%i==0)
            return false;//its definately NOT prime
    }
    //the fact that we even made it here means that it is prime!
    return true;
}
Labdabeta 182 Posting Pro in Training Featured Poster

If it is that urgent, this can be done quickly and easily using the dreaded global variable. Not to recommend extensive use of globals but just this once they could make for an easy solution:

int f1,f2;
void functionOne(/*functionOne arguments*/)
{
    f1++;//increment f1
    //code for function One
}
void functionTwo(/*functionTwo arguments*/)
{
    f2++;//increment f2
    //code for function Two
}
void showCounts()
{
    cout<<"functionOne: "<<f1<<" times.\nfunctionTwo: "<<f2<<" times.";
}
int main()
{
    showCounts();
    functionOne();
    showCounts();
    functionTwo();
    showCounts();
    return 0;
}

That is just an example of course, but you can use this principle in your code if you need to.

Labdabeta 182 Posting Pro in Training Featured Poster

It probably said that std::vector<string> has no function push_back(int) because on line 6 you say v.push_back(1), but v is a string vector, not an int vector.

Labdabeta 182 Posting Pro in Training Featured Poster

I don't see anything wrong. I would suggest for good practice also setting your pointers to null when you deallocate them. I sometimes like to define delarr in a preprocessor macro:

#define delarr(X) (delete[](X));((X)=0)

Hope this helps. (Also I may be wrong so more people should check as well)

Labdabeta 182 Posting Pro in Training Featured Poster
while (!f.fail())
{
    cin>>integervalue;
}
Labdabeta 182 Posting Pro in Training Featured Poster

Here is what I got from http://www.cplusplus.com/reference/iostream/istream/operator%3E%3E/...
I think that you should just input to the int and then check if the failbit was set (you can do this using the fail() function).

Labdabeta 182 Posting Pro in Training Featured Poster

Calm down... the answer to your question is to TRY IT! if you try it you will find that either it works... or it doesn't.

Labdabeta 182 Posting Pro in Training Featured Poster

You are comparing your integer to X. What is X? In this program it is not set as anything.

Labdabeta 182 Posting Pro in Training Featured Poster

just remove the cin.ignore() it is saying "forget the first thing that the user enters" you don't want that.

Labdabeta 182 Posting Pro in Training Featured Poster

From what I can tell your error might be that

while (t.End())

may never be false as it may only be abnorm or norm, which could be true or false. Try:

while (t.End()!=abnorm)

Of course you will need the End() function to return a Status, not a bool.

Labdabeta 182 Posting Pro in Training Featured Poster

Ill try to help, but please put CODE tags around your code so I can read it.

Labdabeta 182 Posting Pro in Training Featured Poster

Well, here is what I would basically do, it takes advantage of some of the methods that std::string contains:

string *BreakUp(string in, int *num)//This translates a command into an array of strings, num will become the length of said array
{
    int numWords=0;//This is the number of words in the command
    for (int i=0; i<in.length(); i++)//loop through the word
    {
        if (in[i]==' ')//if it is a strength
        {
            numWords++;
        }
    }
    *num=numWords;//set num
    string *ret=new string[numWords];//Create the return vector
    for (int i=0; i<numWords; i++)
    {
        ret[i]=in.substr(0, in.find_first_of(' '));//Grab the first word
        in=in.substr(in.find_first_of(' ')+1);//Strip the first word from the string
    }
    return ret;//return the array of strings
}

Of course you would have to take over from there though.

EDIT: DANG WALTP BEAT ME WHILE I WAS WRITING THE CODE!

Labdabeta 182 Posting Pro in Training Featured Poster

The problem is that friend methods don't get passed down to inherited classes. Here is an illustration of what I mean:
Won't work, friend method does not get passed down:

#include <iostream>
using namespace std;
class Base
{
    public:
    friend void out(){cout<<"BASE";}
};
class Derived:public Base
{};
int main()
{
    Derived bob;
    bob.out();
    return 0;
}

Will work, out is inherited from Base:

#include <iostream>
using namespace std;
class Base
{
    public:
    void out(){cout<<"BASE";}
};
class Derived:public Base
{};
int main()
{
    Derived bob;
    bob.out();
    return 0;
}

Hope this helps. (In short I think you will have to either write another << operator or maybe find out the syntax for a virtual << operator overload)