C ++ question

N

NPC

tmnet said:
Dear all,
Below is the question :

Array manipulations, Class, Exception handling, Generic class.

- design, implement and test a set class in c++ that provides the
operations; set membership, set intersection, set union and set diferrence.
An array is to be used to represent a set within a class.

hope you all can help. thank you.

regards,
Michael



Of course some of us can help.

#include <set>

std::set<WhateverTypeUWant> mySet;

OR

#include <vector> // Some array-like data structure
#include <algorithm> // several set-manipulation algorithms

Now, as for us doing your homework for you... I suggest a data structures
book - preferably in C++ if that is the language you are using (but isn't
necessary). Data structures/algorithms can be a lot of fun - they are very
fundamental to all of computer science - fortunately, they also require some
thought and education on the subject. You won't be getting your degree any
time soon if you have others do such fundamental work for you. Believe it
or not, these types of concepts are used in every aspect of computer
science. The sooner you become educated on them, the better off you will be
here.

-NPC
 
T

tmnet

Dear all,
Below is the question :

Array manipulations, Class, Exception handling, Generic class.

- design, implement and test a set class in c++ that provides the
operations; set membership, set intersection, set union and set diferrence.
An array is to be used to represent a set within a class.

hope you all can help. thank you.

regards,
Michael
 
C

Claudio Puviani

tmnet said:
Dear all,
Below is the question :

Array manipulations, Class, Exception handling,
Generic class.

- design, implement and test a set class in c++ that
provides the operations; set membership, set
intersection, set union and set diferrence. An array
is to be used to represent a set within a class.

hope you all can help. thank you.

What will you do when you're at a job interview? Ask for access to the
Internet so you can beg people for an answer to the questions you're being
asked? NO ONE will hire someone who can't think for himself.

I'm being completely serious about this: if you can't solve those kinds of
problems on your own, drop the discipline because you'll just end up
unemployed. Maybe you'd make a good lawyer or a good doctor or a good
mechanic, but no one makes it in the software field without being a problem
solver.

Claudio Puviani
 
D

Daniel T.

tmnet said:
Dear all,
Below is the question :

Array manipulations, Class, Exception handling, Generic class.

- design, implement and test a set class in c++ that provides the
operations; set membership, set intersection, set union and set diferrence.
An array is to be used to represent a set within a class.

hope you all can help. thank you.

//--------------------------------------------------------------------
#include "Set.h"
#include <string>
#include <sstream>

template < typename T >
void check( const T& expected, const T& got )
{
if ( !(expected == got) ) {
std::cerr << "Expected: '" << expected
<< "' got: '" << got << "'" << std::endl;
abort();
}
}

int main()
{
using namespace std;
Set s;
s.addItem( 5 );
check( true, s.contains( 5 ) );

cout << "OK";
}
//--------------------------------------------------------------------

Start with the above. When you try to compile it, a list of errors will
be generated. Fix the first error and then try again. Keep doing this
until it compiles. When it finally runs, start changing what you wrote
until the program prints "OK" on the screen.

Then show me what you have so far and I'll give you another test.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top