C++ Homework, totally clueless

Hi guys, doing some C++ homework atm. I was told to "Implement and test the following class." but I have no idea what that entails in the context of this program. I am also a bit lost on what friend osteam/istream operators mean. Essentially I don't know where he wants us to start, my brain keeps reading it as a program that's finished for some reason and so I don't know what I need to add.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  
class Vector
{  
  friend ostream &operator<<( ostream &, const Vector &);
  friend istream &operator>>( istream &, Vector &);
public:
Vector( int = 10);
Vector( const Vector & );
~Vector();
int getSize() const;
const Vector &operator=( const Vector &);
bool operator==( const Vector &) const;
bool operator!=( const Vector &right) const
{ return ! (*this == right ); }
int &operator[]( int );
int operator[]( int ) const;
private:
int size;
int *prtr;
};
friend means that the class can access the friend class private members. Here some info on this site about it.
http://www.cplusplus.com/doc/tutorial/inheritance/

And I'm assuming he wants you to finish writing the member functions of the class. Here a small little example of the ostream overload I wrote to show you what that can be done.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

class C
{
public:
	C(int a, int b) : a(a), b(b) {}

	friend std::ostream &operator<<(std::ostream& os, const C& c)
	{
		os << "A: " << c.a << " - B: " << c.b;
		return os;
	}

private:
	int a;
	int b;
};


int main()
{
	C c(10, 15);
	std::cout << c << '\n';

	return 0;
}


And that just prints
A: 10 - B: 15

Topic archived. No new replies allowed.