473,387 Members | 1,517 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,387 software developers and data experts.

Error message

Hi I am doing a program of sets using overloaded methods.
But I am having some error because supposedly the method isValid is
undeclared.
He is some part of my program.

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

class IntegerSet
{
private:
bool set[26];
int element;

public:
//Methods
IntegerSet(); //default
Constructor
IntegerSet(int x[], int k); //overload
constructor

bool isValue(int);
void insertElement(int);
void deleteElement(int);
void setString();
void inputSet();
};

//methos isValid
bool IntegerSet::isValid(int i)
{
return set[i];
}

Thanks.

Nov 11 '07 #1
11 2109
On Nov 10, 6:07 pm, Latina <sdl...@gmail.comwrote:
Hi I am doing a program of sets using overloaded methods.
But I am having some error because supposedly the method isValid is
undeclared.
He is some part of my program.

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

class IntegerSet
{
private:
bool set[26];
int element;

public:
//Methods
IntegerSet(); //default constructor
IntegerSet(int x[], int k); //overload constructor

bool isValue(int);
void insertElement(int);
void deleteElement(int);
void setString();
void inputSet();

};
This is the error message pointing where the arrow is:
no `bool IntegerSet::isValid(int)' member function declared in class
`IntegerSet'
//methos isValid
bool IntegerSet::isValid(int i)
--{
return set[i];
}

Thanks.

Nov 11 '07 #2
class IntegerSet
{
<snip>
bool isValue(int);
<snip>
};

//methos isValid
bool IntegerSet::isValid(int i)
{
return set[i];

}
isValue is not the same as isValid. One or the other is misspelled.
Or maybe both.

Michael

Nov 11 '07 #3
isValue is not the same as isValid. One or the other is misspelled.
Or maybe both.

Michael
oops I didnt notice that, thanks
but I still have some other errors.

error: `isValid' undeclared (first use this function)

(where the arrow is pointing)
IntegerSet operator+(IntegerSet &right)
{
IntegerSet j;

for(int element=0; element<=25; element++)
{
-- if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}

Nov 11 '07 #4
Latina schrieb:
but I still have some other errors.

error: `isValid' undeclared (first use this function)

(where the arrow is pointing)
IntegerSet operator+(IntegerSet &right)
{
IntegerSet j;

for(int element=0; element<=25; element++)
{
-- if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}
Is operator+ a member of class IntegerSet? If it is, isValid will be
called with *this. If operator+ is not a member of class IntegerSet you
have to call it with an object.

Martin
Nov 11 '07 #5
On Nov 11, 8:50 am, Martin Engelmann <martin.engelm...@gmx.dewrote:
Latina schrieb:


but I still have some other errors.
error: `isValid' undeclared (first use this function)
(where the arrow is pointing)
IntegerSet operator+(IntegerSet &right)
{
IntegerSet j;
for(int element=0; element<=25; element++)
{
-- if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}

Is operator+ a member of class IntegerSet? If it is, isValid will be
called with *this. If operator+ is not a member of class IntegerSet you
have to call it with an object.
if i use *this gives me this error
--invalid use of `this' in non-member function

Nov 11 '07 #6
Latina schrieb:
On Nov 11, 8:50 am, Martin Engelmann <martin.engelm...@gmx.dewrote:
>Latina schrieb:
>>but I still have some other errors.
error: `isValid' undeclared (first use this function)
(where the arrow is pointing)
IntegerSet operator+(IntegerSet &right)
{
IntegerSet j;
for(int element=0; element<=25; element++)
{
-- if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}
Is operator+ a member of class IntegerSet? If it is, isValid will be
called with *this. If operator+ is not a member of class IntegerSet you
have to call it with an object.

if i use *this gives me this error
--invalid use of `this' in non-member function
So you should either make operator+ a member function of IntegerSet or
add a second parameter to the function.

IntegerSet IntegerSet::operator+(IntegerSet &right)
(my recommendation)
or
IntegerSet operator+(IntegerSet &left, IntegerSet &right)

When using a non-member function you have to change the condition to
if(left.isValid(element) || right.isValid(element))
Nov 11 '07 #7
On Nov 11, 10:45 am, Martin Engelmann <martin.engelm...@gmx.dewrote:
Latina schrieb:


On Nov 11, 8:50 am, Martin Engelmann <martin.engelm...@gmx.dewrote:
Latina schrieb:
but I still have some other errors.
error: `isValid' undeclared (first use this function)
(where the arrow is pointing)
IntegerSet operator+(IntegerSet &right)
{
IntegerSet j;
for(int element=0; element<=25; element++)
{
-- if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}
Is operator+ a member of class IntegerSet? If it is, isValid will be
called with *this. If operator+ is not a member of class IntegerSet you
have to call it with an object.
if i use *this gives me this error
--invalid use of `this' in non-member function

So you should either make operator+ a member function of IntegerSet or
add a second parameter to the function.

IntegerSet IntegerSet::operator+(IntegerSet &right)
(my recommendation)
or
IntegerSet operator+(IntegerSet &left, IntegerSet &right)

When using a non-member function you have to change the condition to
if(left.isValid(element) || right.isValid(element))- Hide quoted text -

Ok, I declared like this and this is the error I am getting
"expected init-declarator before '+' token ":

class IntegerSet
{
public:
//Operator methods.
IntegerSet &operator+(const IntegerSet &right);
//overloaded operator + to compute the union of two sets
--IntegerSet IntegerSet::perator+(IntegerSet &right)
{
IntegerSet j;

for(int element=0; element<=25; element++)
{
if(isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}

But if I do it like this I am getting the same error
"expected init-declarator before '+' token"

//overloaded operator + to compute the union of two sets
--IntegerSet perator+( &left, IntegerSet &right)
{
IntegerSet j;

for(int element=0; element<=25; element++)
{
if(left.isValid(element) || right.isValid(element))
j.insertElement(element);
}
return j;
}

Nov 11 '07 #8
Ok, I got it but now I am getting this error:
" passing `const IntegerSet' as `this' argument of `bool
IntegerSet::isValid(int)' discards qualifiers "
//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;
}

Nov 11 '07 #9
Latina wrote:
Ok, I got it but now I am getting this error:
" passing `const IntegerSet' as `this' argument of `bool
IntegerSet::isValid(int)' discards qualifiers "
//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;
}
Most likely 'isValid' is not declared 'const' (unlike 'operator+'
here, for example)

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 11 '07 #10
On Nov 11, 4:14 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Latina wrote:
Ok, I got it but now I am getting this error:
" passing `const IntegerSet' as `this' argument of `bool
IntegerSet::isValid(int)' discards qualifiers "
//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;
}

Most likely 'isValid' is not declared 'const' (unlike 'operator+'
here, for example)

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide quoted text -
Ok, thanks
Nov 11 '07 #11
I have another error where the arrow is.

Error: " `IntegerSet IntegerSet::operator!(const IntegerSet&)' must
take `void' "

class IntegerSet
{
public:
//Operator methods.
IntegerSet operator + (const IntegerSet &)const; //Method
union
IntegerSet operator * (const IntegerSet &)const; //Method
intersection
-- IntegerSet operator ! (const IntegerSet &)const; //Method
complement

//overloaded operator ! to compute the complent of a set
IntegerSet IntegerSet::operator!(IntegerSet &right)const
{
IntegerSet j;

for(int element=0; element<=25; element++)
{
if(!isValid(element))
j.insertElement(element);
}
return j;
}

Nov 11 '07 #12

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

Similar topics

10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
9
by: Mairhtin O'Feannag | last post by:
Hello, We have two machines we wish to use DPF. They are both RH ES 2.1, with DB2 8.2. I read the documentation CAREFULLY, and added the following line to my db2nodes.cfg file : 1 egret 0
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.