473,325 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

C++ program error message

Hi I am doing a program overloaded operator.
I am having a few errors on it.
Error1: request for member `insertElement' in `S1set', which is of non-
class type `IntegerSet[26]'
Error2: no matching function for call to `IntegerSet::operator+
(IntegerSet[26])'
Here is my program:
class IntegerSet
{
private:
bool set[26];
int element;
public:
//Operator methods.
IntegerSet operator + (const IntegerSet &)const; //Method
union
//Methods
IntegerSet(); //default
constructor
IntegerSet(int x[], int k); //overload
constructor
bool isValid(int)const;
void insertElement(int);
void deleteElement(int);
void setString();
void inputSet();
};
IntegerSet set();
IntegerSet::IntegerSet()
{
for(element=0; element>=25; element++)
set[element]= false;
}
IntegerSet::IntegerSet(int x[], int k)
{
for(element=0; element>=25; element++)
set[element]= false;
for(int j=0; j<k; j++)
{
element=x[j];
set[element]= true;
}
}
bool IntegerSet::isValid(int i)const
{
return set[i];
}
//insert element to a set
void IntegerSet::insertElement(int element)
{
set[element]=true;
}
//delete element of a set
void IntegerSet::deleteElement(int element)
{
set[element]=false;
}
//overloaded operator + to compute the union of two sets
IntegerSet IntegerSet::operator+(const IntegerSet &right)const
{
IntegerSet j;
for(int element=0; element<=25; element++)
{
if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}
int main()
{
IntegerSet run;
IntegerSet S1set[26];
IntegerSet S2set[26];
IntegerSet S3set[26];
IntegerSet Sset[26];
for(int i=2; i<=20; i+2)
S1set.insertElement(); <--Error 1
for(int k=6; k<=21; k+3)
S2set.insertElement(); <--Error 1
for(int j=3; j<=18; j+6)
S3set.insertElement(); <--Error 1
for(int z=0; z<=25; z++)
Sset.insertElement(); <--Error 1
run.inputSet();
int choice;
cout<<"\n WELCOME to the INTEGER SET PROGRAM\n";
cout<<"\n\nSelect one of these choices\n";
cout<<" 0. Create set \n";
cout<<" 1. Find Union \n";
cin>>choice;
if(choice==0)
{
int temp, ele;
int newSet[26];
cout<<"Enter how many elements you want in the set: "<<endl;
cin>>ele;
for(int i=0; i<ele; i++)
{
cout<<i+1;
cin>>temp;
newSet[i]=temp;
}
}
else if(choice==1)
{
char a, b, c, d;
int option;
cout<<"Select one of this choices";
cout<<"a. To find the union of the set you enter and the set
'S'";
cout<<"b. To find the union of the set you enter and the set
'S1'";
cout<<"c. To find the union of the set you enter and the set
'S2'";
cout<<"d. To find the union of the set you enter and the set
'S3'";
cin>>option;
if(option=='a'||option=='A')
{
run.operator+(Sset); <--Error 2
}
else if(option=='b'||option=='B')
{
run.operator+(S1set); <--Error 2
}
else if(option=='c'||option=='C')
{
run.operator+(S2set); <--Error 2
}
else if(option=='d'||option=='D')
{
run.operator+(S3set); <--Error 2
}
}
return 0;
}

I hope some one can help me.

Nov 12 '07 #1
2 3059
Ok, thanks.
I got it ^_^

Nov 13 '07 #2
On Nov 12, 2:22 pm, Michael DOUBEZ <michael.dou...@free.frwrote:
Michael DOUBEZ a écrit :
[...]
public:
//Operator methods.
IntegerSet operator + (const IntegerSet &)const; //Method
union
* union method could be better described by operator|() since it is
effectively what you are doing.
On the other hand, it has the wrong precedence:-).

My SetOfCharacter class supports both, with the "rationale" that
+ adds members to the set, and - removes them. (The "rationale"
seriously breaks down, however, when I allow * for the
intersection:-).)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BKM | last post by:
I'm using a VB6 WebBrowser control to get info from various web pages and, occasionally, my program stops when it finds a script error on the page. It won't resume until I click 'Yes' or 'No' on...
5
by: aleksander.helgaker | last post by:
I've completely rewritten a calculator I wrote to help me learn Python. After someone told me about the def command I reliesed that I could make the program much better, but there is a very anoying...
8
by: Toni | last post by:
Hello I'm a newbie in VB .NET and I'd like to accomplish a (I think) very simple task. What I want to do is throw an error message to the user whenever something happens. The main point is...
2
by: William Payne | last post by:
Hello. Consider the following code snippet (pseudo-code). void foo() { /* do stuff */ if fatal error occurs { throw "error message"; }
5
by: jose luis fernandez diaz | last post by:
Hi, In the program below: #include <stdio.h> #include <stdlib.h> #include <errno.h> using namespace std; int main()
1
by: Mark | last post by:
When the following VB code is executed (code from an aspx page), the following error message is issued: "Microsoft Access can't open the database because it is missing, or opened exclusively by...
1
by: MAL | last post by:
Hello, I have 2 classes that work great as a windows app to retrieve and process data from an Oracle9i db. When I implement them in a Service program running as Local System, it fails on the...
1
by: brainstormer | last post by:
I'm new to this site and seeking help with an Error message. I have a program in HP called Image Zone. A few weeks ago all my photos disappeared and I got this error message..."Object reference not...
1
by: shrinkla | last post by:
I was trying to update my program and "imported" a file over the network into the program (not a virus or other problem as it came from another computer in the network). Since doing this the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.