I would get rid of that table to align those "Previous 10" and "Next 10" buttons.

That being said, the duplicate of the arrow is caused by a [CODE]background: inherit;[/CODE] in main.css line 57. Remove it and you're fine.

Then you can get this ugly table to fall below the last item if you add to your table a clear: both;

I have to say that I'm also a bit at a loss here...

As you point out, the function prototype is passing the stack by value, so it's copying the stack. That function can do whatever it wants with the copy, and when returning from this function, this copy will be destroyed. This function doesn't return anything, so no chance to return the sum...

To me the code [ICODE]total = sumStack(mystack)[/ICODE] will make the compiler complain, as your trying to assign [I]void[/I] to total.

I assume I didn't understand correctly the question or the givens. Sorry. (still a noob too ;) )

You didn't do this [ICODE]# use cin.get(box) to get the box number and isdigit to verify it is a number;[/ICODE]

And you will probably need somewhere in your TicTacToe class a function checking if the game is over. There are 3 different cases : player X won, player Y won or it's a tie. Having such a function would be helpful, as you could write something like
[CODE]
class TicTacToe
{
public:
bool gameOver() // Returns true when game is over. Could maybe set some private variable with who the winner is or if it's a tie.
//Rest of class definition
// [...]
};
int main(){
while(!ttt.gameOver()) // While the game has not ended
{
ttt.playGame();
}
}
[/CODE]

Line 17 of your main.cpp[ICODE]setup(team one, team two, team three, team four, team five, team six, team seven, team eight);[/ICODE]. When you call a function you don't write the type of the parameters passed. You only write the parameters themselves. So you should call [ICODE]setup(one, two, three, four, five, six, seven, eight);[/ICODE].

Also be careful with the instantiation of your teams. [ICODE]team one = {" ",0,0,0,0,false};[/ICODE]. There are 5 int in your struct followed by a bool. What happens here is that the bool value is assigned to your score (the last int) and the progress is not set at all.

[ICODE]board[i][/ICODE] should hold either 1-9 or an X or an O. But in your [ICODE]void TicTacToe::displayBoard()[/ICODE] you reset the values of [ICODE]board[][/ICODE] to their original values.

The "initialization" of your game variables should come in a constructor. That's where you could set the values 1-9 in your board array. Then [ICODE]void TicTacToe::displayBoard()[/ICODE] would just output whatever board array holds.

And if you know what it means to pass by reference, you will probably want to do that, in order to save the cost of a copy-destruction.

[CODE]
struct team
{
string name;
int skill;
...
}

void SimulateMatch(const team& t1, const team& t2)
{
...
}
[/CODE]

It seems you'll need to be able to compare dates and times. I would give [URL="

When you insert an element in a linked list, what is the programming actually doing ? What happens to the current pointer ?

I don't know if you did some mistake in your copy-paste, but this code seems to have a few issues...

You're asking for lowerDate and upperDate within the for loop. Is this really intended ? I would assume you ask that once, and loop over the vector to insert the relevant elements in the set.

You are comparing lowerDate and upperDate with PriceInfo.Date. All are defined as strings. I guess you don't want that. You want to compare dates chronologically, right ?

I tried this code (similar to yours)
[CODE]

include <iostream>
include <iterator>
include <vector>
include <algorithm>
include <string>
include <sstream>
include <fstream>

struct PriceInfo
{
double Open;
double High;
double Low;
double Close;
unsigned int Volume;
unsigned int Time;
std::string Date;
};

template <typename T>
void ReadCommaSeparatedValue(std::istream& istream, T& t)
{
std::string value;
std::getline(istream, value, ',');
std::istringstream valueStream(value);
valueStream >> t;
}

std::istream& operator>>(std::istream& istream, PriceInfo& priceInfo)
{
std::string ignored;
std::string line;
std::getline(istream, line);
std::istringstream lineStream(line);
ReadCommaSeparatedValue(lineStream, ignored); // ignore field 0
ReadCommaSeparatedValue(lineStream, ignored); // ignore field 1
ReadCommaSeparatedValue(lineStream, priceInfo.Date);
ReadCommaSeparatedValue(lineStream, priceInfo.Time);
ReadCommaSeparatedValue(lineStream, priceInfo.Open);
ReadCommaSeparatedValue(lineStream, priceInfo.High);
ReadCommaSeparatedValue(lineStream, priceInfo.Low);
ReadCommaSeparatedValue(lineStream, priceInfo.Close);
ReadCommaSeparatedValue(lineStream, priceInfo.Volume);
// ReadCommaSeparatedValue(lineStream, ignored); // ignore field 9
return istream;
}

std::ostream& operator<<(std::ostream& ostream, PriceInfo& priceInfo)
{
ostream << "Date:" << priceInfo.Date << " Time:" << priceInfo.Time
<< " Open:" << priceInfo.Open << " High:" << priceInfo.High
<< " Low:" << priceInfo.Low << " Close:" << priceInfo.Close
<< " Volume:" << priceInfo.Volume << std::endl;
return ostream;
}

template <typename T>
std::istream& operator>>(std::istream& istream, std::vector<T>& vector)
{
std::copy(std::istream_iterator<T>(istream), std::istream_iterator<T>(), std::back_inserter(vector));
return istream;
}

int main()
{
std::ifstream dataFile("data.txt");
std::vector<PriceInfo> prices;

dataFile >> prices;

std::copy(prices.begin(), prices.end(), std::ostream_iterator<PriceInfo&>(std::cout,""));

return 0;

}
[/CODE]
With these data
data.txt
[CODE]0,1,13/02/2011,1230,10,20,5,13,500
0,1,14/02/2011,1530,20,30,10,15,1000[/CODE]

And it's working properly... I get two lines with the first two values ignored.
Of course my code is not checking if dataFile is ok. But it was just to find out if it's working or not. Notice I didn't use a while loop but just once the >> operator.

After some thoughts and readings, I think I was wrong, and copy works as you intended.

I would try anyway the push_back idea to make sure that function operator>>(istream&, PriceInfo&) is working as intended. Maybe you could post two lines of your csv file ?

I suspect that std::copy is not doing what you think it's doing.
[QUOTE]The behavior of this function template is equivalent to:
[CODE]
template<class InputIterator, class OutputIterator>
OutputIterator copy ( InputIterator first, InputIterator last, OutputIterator result )
{
while (first!=last) result++ = first++;
return result;
}[/CODE]
[/QUOTE]
So you're taking the first element from the stream, which is probably your [I]ignore field 0[/I] and try to assign it to a PriceInfo object which will be inserted in your vector. But you're not calling the operator>>(istream&, PriceInfo&).

I would write
[CODE]
PriceInfo prInfo;
while(dataFile >> prInfo)
{
prices.push_back(prInfo);
}
[/CODE]

To read your file, did you try instead :
[CODE]
while (dataFile >> prices)
{
}
[/CODE]

I think eof() will only return true when you actually tried to read beyond the end of file.

Or you could use STL to do this for you applying the floor function on your vector and returning the result in another vector.

[CODE]

include <vector>
include <cmath>
include <algorithm>
include <functional>

int main()
{
typedef std::vector<double> Vec;
Vec first;
//Fill this vector with double values

Vec second(first.size());
std::pointer_to_unary_function <double, double> floorObject(std::floor);
std::transform(first.begin(), first.end(), second.begin(), floorObject);

return 0;

}

[/CODE]

mrnutty commented: Nice, didn't know about pointer_to_unary_function +13

You have to place your template class definition in the same place as the declaration.
See [URL="

As I said, I didn't try my code. Indeed I defined the operator<< inside the OrderTree class, and it then passes [I]this[/I] as the first parameter, which is not what I wanted. So here is another attempt... Tell me if that's working for you ?

main.cpp
[CODE]
//////////////////////////////////////////////////////////////
//////main.cpp///
/////////////////////////////////////////////////////////////
//////Author:xxxxxxxxxxxxxx
/////////////////////////////////////////////////////////////
//////Student number:xxxxxxxxx
/////////////////////////////////////////////////////////////
//////Date of creation:July 14,2011
/////////////////////////////////////////////////////////////

include "Tree.h"
include <iostream>
include <string>
include <fstream>
include <string>
include <sstream>

using namespace std;

using std::cout;
using std::cin;

OrderTree tree;
void load() //inserting words from a file into the tree.
{
string filename;
//the variable of type ifstream:
std::cout << "Please enter the desired filename with it's extension:\t ";
std::cin >> filename;

const char *file=filename.c_str();
std::ifstream myfile(file, std::ios::in);

if (!myfile.is_open())
{
    cout << "Can't open file\n";
}
else if (myfile.is_open())
{
    string line;

    // read one line at a time
    while (getline(myfile, line))
    {
        stringstream sstrm(line);
        std::string English;
        std::string Klingon;

        if(getline(sstrm, English,':'))
        {
            sstrm >> Klingon;
            cout <<English<<":"<< Klingon <<endl;
            // two words extracted
            tree.insert(Order(English, Klingon));
        }
    }
}

}
void insert() //inserting a word into the tree.
{
std::cout <<
"Insert a word into the tree\n"
"Enter a Word:\n <English> : <Klingon> ";
std::string English;
std::string Klingon;
std::cin >> English;
// std::cout << "";
std::cin >> Klingon;
tree.insert(Order(English, Klingon));

cout <<English<<":"<< Klingon <<endl;
}

void remove() //removing a word
{
std::cout << "Remove a word" << std::endl;
std::cout << "Enter word: ";
std::string English;
std::cin >> English;
std::cout << tree.remove(English) << std::endl;
}

void search() //searching for a ...

As you said, you need to put the whole tree in your file. So you need to traverse it and output that in your file. I assume you want the output to look similar to your print : <English>:<Spanish>.

In Order.h
[CODE]
std::ostream& operator<<(std::ostream &s, const Order &o) // print
{
s << o.English() << ":" << o.translation() << std::endl;
return s;
}
[/CODE]
In tree.h
[CODE]
class OrderTree
{
//private members of the class
private:

struct Node // bst as a reference structure made up of nodes
{
Node left;
Order data;
Node
right;
Node(): left(0), right(0) {}
Node &operator=(const Node &v)
{
left = v.left;
data = v.data;
right = v.right;
return *this;
}
};

std::ostream& operator<<(std::ostream& o, const Node* nod)
{
if (nod)
{
o << nod->left;
o << nod->data;
o << nod->right;
}
return o;
}

//Rest of the private code for OrderTree comes here

public:
const Node* getRoot() {return root;} //returns the root of the Tree

//Rest of the public code for OrderTree comes here

};

//And out of the OrderTree class definition
std::ostream& operator<<(std::ostream& o, const OrderTree& ordtree)
{
o << ordtree.getRoot();
return o;
}
[/CODE]
And in main.cpp
[CODE]
void up()
{
fstream file("example.txt", ios::out); //open for output
file << tree;
file.close();
}
[/CODE]
As I don't have your code, I can't test what I suggest. It's probably full of little mistakes, but you'll get the general idea. You need for each of your class/structs to define how to overload the operator<<.

Ok, in that case, would you please post your latest code (order.h, tree.h and main.cpp) ?

Would you please explain what's the goal of your project ? I understood it was some kind of dictionary, but now you're saying that the English word is actually an unsigned int ? That's confusing me.

Hey Narue,

Thanks a lot for all the clarifications ! Indeed I'm only a noob. But I tried to help another noob. I'm glad my post made you react and correct it. Now the OP will have an answer. :)

By assignment constructor, I meant assignment operator. But as you pointed out, I'm still not quite there yet. :)

In your example code, you write [ICODE]foo(foo&&) { cout << "foo(foo&&)\n";[/ICODE]. I guess you meant [ICODE]foo(foo&) { cout << "foo(foo&)\n";[/ICODE] ? Because I'm anaware of && (and my compiler seems to complain.

I tried your code out of curiosity, and it was very interesting to find out that there's only on call to a constructor. Indeed the compiler (hopefully) makes some good optimizations. I nevertheless thought it would be useful (though not always accurate) to make someone realize that it's not because you don't explicitly write a copy constructor (or constructor, etc) that you don't end up with one.

I'm sure you find all this so trivial. So sorry if this was a too "low level" answer.

First of all, your method is [ICODE]inOrderPrint_[/ICODE] but in the function up() you call [ICODE]tree.inOrderPrint()[/ICODE]

I would actually consider overloading the operators << and >> for the OrderTree class. So you could just write [ICODE]cout << tree;[/ICODE]

So you could define in your Tree.h header the following functions :
[CODE]
&istream operator<<(const OrderTree& tree, const istream& in)
{
//Have some way to go through your tree like DFS or BFS and for each data you do
in << tree.data << std::endl;

//After going through all your tree, just return the stream
return in;

}

&ostream operator>>(const OrderTree& tree, const ostream& out)
{
//Have some way to go through your tree like DFS or BFS and for each data you do
out >> tree.data >> std::endl;

//After going through all your tree, just return the stream
return out;

}
[/CODE]

Maybe if you would post the entire Tree.h, I could help a bit more...

[QUOTE=sha11e;1603630]
Could someone explain that code?

Like...

  • how can you do foo a = 11 ?
    foo is a class, a the object. The constructor takes an int, so shouldn't it be
    foo a (11) ?

  • what does the "explicit" bar(... do? -why cant you do bar b = 11

  • how can you have foo(int) ? don't you need a variable name? foo(int whatever) ?[/QUOTE]
    There are four things that the compiler will create for you in a class unless you tell it otherwise : a default constructor, a copy constructor, an assignment constructor and a destructor.

When you write in the example above [ICODE]foo a = 11;[/ICODE] you are doing actually three things in one line ! First you create an object foo called a. This object is initialized without any parameter (no int given), so the compiler will just initialize it with something (0 most of the times, but I think it's actually undefined behavior). Next you try to assign to your object a an integer... The compiler doesn't like that too much. How is he able to deal between banana and apples (foo object and int) ? But he's got one last chance : he's looking if maybe he could instantiate an object foo with this 11 given. And it finds that actually you can construct a foo object with one int, so he does so. Now he can assign this foo object initialized with 11 to the 'a' object, by using the default ...

Just a wild guess. Would there be a problem because Windows end of line are \r\n, while Unix end of line are \n only ?

In your load() code, I see a problem. You read a piece of a line with [ICODE]while (getline(myfile, line,':'))[/ICODE] because it stops at the first ':' it finds. Instead you should read the whole line, then make a stringstream and read until the ':'.

Here is another version which seems to work
[CODE]
void load() //inserting a word into the tree.
{
string filename;
//the variable of type ifstream:
std::cout << "Please enter the desired filename with it's extension:\t ";
std::cin >> filename;

const char *file=filename.c_str();
std::ifstream myfile(file, std::ios::in);

if (!myfile.is_open())
{
    cout << "Can't open file\n";
}
else if (myfile.is_open())
{
    string line;

    // read one line at a time
    while (getline(myfile, line))
    {
        stringstream sstrm(line);
        std::string English;
        std::string Spanish;

        if(getline(sstrm, English,':'))
        {
            sstrm >> Spanish;
            cout <<English<<":"<< Spanish <<endl;
            // two words extracted ...
            tree.insert(Order(English, Spanish));
        }
    }
}

}
[/CODE]

For your up() function, I don't know how your Tree.h is implemented and so how the function [ICODE]tree.inOrderPrint();[/ICODE] works.
I'm just puzzled by [ICODE]file.seekp(6, ios::beg); //move the put cursor to start of "text"[/ICODE]. What are you trying to achieve with this ?

With the inheritance you have, the base class has to be constructed before the derived class. Hence your second option is the right one.

Now I totally support Jonsca comment. A circle is not a point. So Circle shouldn't derive from Point. I would write
[CODE]
class circle
{
private:
int radius;
point p;
public:
circle(const point & p, int r);
int getRadius() const { return radius; } // Added const as this member funct doesn't change the Circle class.
const point & getCenter() const {return p;} // Added this other funct to get the center.
bool operator>(const circle & c); // Less time consuming to pass it by reference
};

circle::circle(point p, int r) : radius(r), p(p)
{
}

// The rest remains unchanged.
[/CODE]

For your point class, I would also make these small changes

[CODE]
class point
{
private:
int x, y;
public:
point() {} // Do you need this one ? I would make default parameters for the next constructor.
point(int x=0, int y=0);
point(const point& d); // Do you need this ? The default copy constructor will just do the same.
int getX() const { return x; } // Again some constness...
int getY() const { return y; }
};

point::point(int x=0, int y=0) : x(x), y(y)
{}
[/CODE]
When you write
[CODE]point::point(int x, int y) { this -> x = x; this -> y = y;}[/CODE]
This is wrong. All data members are initialized before entering the constructor. For built-in types there's no guarantee ...

Here are a few things you might have overlooked :

When you write [code]long int A[29];[/code] what you are doing is to create an [I]array[/I] of 29 long int. Your variable A is a pointer to the beginning of this array. If you write [CODE]cout << *A;[/CODE] you would print on the console the first long int of the Array. But it's more convenient to access the array using indices, so writing A[0]. The indices start at 0. As you defined 29 elements of this array, and if the first as an index of 0, the last one will have and index od 28 (so the size of your array - 1).

You said you want to create arrays of 30 elements, so you would write long int A[30]; but you would access them from A[0], ..., A[29]. As said above, why long int ? Each element in the array will hold only one digit. An simple int will do just fine. :)

You seem to overlook the scope of your variables, and how you pass them to functions. If you define a variable in your main() function, it will only exist there, unless you pass it to another function. But by default you pass it to a function [U]by value[/U]. That means that the function will make a [I]local[/I] copy of whatever you pass, but will not affect your variable from main() in any way. To allow another function to manipulate a variable from your main, you should pass ...

Glad I could help. :)

[QUOTE=flasp;1452197]M8 the next chapter is about if statments... It have to be done with a do-while, while or for loop.. Without logical expression as &&.. !0=, ==, => things is fine, cause its in the chapter with the assignment... Thanks for the help though...[/QUOTE]
And do...while is what you should use, as I wrote below my code. The code was just given as an example which shows something that will not work.

So basically you will use a
[code]
do
{
// Insert the code you want to repeat until 0 is entered
}while(numbers != 0)
[/code]
So this do...while will be wrapped around the largest part of your code, repeating it as long as the user doesn't enter 0.

You should wrap your menu + switch statement in a do while loop, so from line 13 to line 75. The condition for the while would be that (again == 'y'). Btw, I don't see much use for the variable n.

You might find this interesting : [URL="