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

does anyone know how to define the method/function The positionOf() method

The positionOf() method, it is declared as private in the private section of the set class declared in the .h file. You define the method the exact same way you define public methods, in the .cpp implementation file for the class. The private means you can call this method from any class method but not from outside the class, for instance, in the main method.

int set::positionOf(SET_ELEMENT_TYPE searchElement)

Returns the position of searchElement or -1 if not found by sequentially searching the vector for the searchElement.

Use a for loop to locate the searchElement if it is in the vector. Use the four iterator methods in the for loop: first(); !isDone(); next() and use currentItem() to check if it is equivalent to the searchElement. If the searchElement is found return the value stored in my_index.

If not found, outside the for loop return -1, meaning the searchElement was not found
Aug 10 '10 #1
1 1453
newb16
687 512MB
To define it one first need to know what is the set class it belongs to (its declaration). The requirements mention "four iterator methods" one of them is "first()" but what type does it return? They expect something like common stl iterator usage
int index = 0;
for(iterator_type it = first(); !isDone(); next(), index++)
{
if (it.currentItem() == searchElement)
return index;
}
return -1;
Aug 10 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: scott | last post by:
Hi, Does anyone know how to enable ASPX on IIS6 ? Thanks Scott
2
by: steve deno | last post by:
In 6i, if there was an LOV on an item and the user entered the field, a box with 3 dots popped up. It seems this does not happen in 9i. Does anyone know why? And how to make that happen? ...
5
by: Silvio | last post by:
Here's my update statement: UPDATE Item1 SET reviewloop = 1, currentreviewstate=5 WHERE itemid in (SELECT itemid FROM Item2) The thing is: the table Item2 DOES NOT HAVE a field called...
5
by: Clifford W. Racz | last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML) into xHTML? I have been trying to get the nested table code for my XSLT to work for a while now, with no way to get the...
5
by: Simon Egginton | last post by:
Does anyone know how to make a CHAT ROOM for a webpage using java or jave script please. I am just look at you lot because i think you are the experts! THANK YOU! ewhost_simon"HI"@yahoo.co.uk...
5
by: Shapper | last post by:
Hello, I know this has nothing to do with ASP.Net but since I know people in this forum know a lot about programming maybe someone knows this: Does anyone know a good javascript forum? I need...
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
8
by: Neil Rowe | last post by:
Hi all I am writing an App at the moment and I need to be able to download & Upload xml files from an ftp server. Does anyone know how this can be done without using a third party component. ...
15
by: Pucca | last post by:
I'm getting an error when I tried to use this BerConverter class in my C# code. Even though the Interent doc says that it runs on Win2000 sp4, I just thgouth I'll double check. Does anyone know...
0
by: janithn | last post by:
rss- does anyone know how to embedd rss into my web template for a news site? basically im creating a news website and i want to use RSS to put in articles. Im using MS Frontpage. Does anyone...
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)...
0
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...
0
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.