Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 01-29-2005, 08:28 PM   #1
Beta Member
 
weezer562's Avatar
 
Join Date: Jan 2005
Posts: 1
Send a message via AIM to weezer562 Send a message via MSN to weezer562 Send a message via Yahoo to weezer562
Default need help

well the assignment is to develop an abstract type for handling characters. Only handling 26 capital letters. I have this need help with CharSet.cc

Code:
//CharSet.h

class CharSet
{
   private:
          bool Contents [26];

   public:
          CharSet(); //constructor initializes set to be empty

          void Add(char Value); //add character to set corresponding bool set to 
                                                     true
          void Remove(char Value);  //Removes char corresponding set to true

          void Union(CharSet ASet); //Union the set passed a parameter into set

          void Intersect(CharSet ASet); //Intersects set passed a parameter
                                                          contains results of intersection
          bool Member(char Value) const; 
}//end class CharSet
Also have testSet.h which is my test
Code:
#include "Charset.h"
#include <iostream>
using namespace std;
void printSet(CharSet ASet)
{
     for (char c = 'A' ; c <= 'Z' ; c++)
     {
          if (ASet.Member (c))
          {
               cout << c;
          }; //end if
     }; //end for
     cout << endl;
}; //end printSet
int main()
{
   CharSet Set1;
   CharSet Set2;
   CharSet Set3;

   Set1.Add('A');
   Set1.Add('B');
   Set1.Add('C');
   Set2.Add('B');
   Set2.Add('C');
   Set2.Add('D');
   Set3.Add('A');
   Set3.Add('B');
   Set3.Add('C');

   Set1.Intersect(Set2);
   Set3.Union(Set2);
   Set2.Remove('C');
   cout << "Expect BC" << endl;
   printSet(Set1);
   cout << "Expect ABCD" << endl;
   printSet(Set3);
   cout << "Expect BD" << endl;
   printSet(Set2);
   return 0;
}; //end main
thats what i have I really stuck on what to write in CharSet.cc and I was wondering if anyone could help me get started or anything. I can't even really think about how to set up the constructor and each function.

Any help would be appreciated.
Thanks
weezer562 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:17 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0