473,398 Members | 2,188 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,398 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 2110
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.