473,671 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

7 New Member
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_TY PE 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 1467
newb16
687 Contributor
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_ty pe 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
10719
by: scott | last post by:
Hi, Does anyone know how to enable ASPX on IIS6 ? Thanks Scott
2
5235
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? Thanks in advance
5
2815
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 itemid. So, I should receive an error, right? Not so.Instead, every single record in Item1 was updated.
5
7410
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 collection that I need. To begin, I am using xsltproc that conmes with Cygwin as my processor. I have no particular affinity to this processor except that it is open source and standards compliant. I don't like M$, but if using a M$ processing...
5
1943
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 remove "HI"
5
288
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 to get some help on a preload images function. Thank You, Miguel
2
2316
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 is called "Contoso", but I can't find it in the MSDN site, so I can evaluate it with the webcasts. If anyone know here is it, or if anyone is using it, please post here a
8
2285
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. Regards Neil
15
2569
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 if BerConverter is supported for Win2000 server? http://msdn2.microsoft.com/en-us/library/system.directoryservices.protocols.berconverter.decode.aspx -- Thanks.
0
1431
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 know how to embbed a feed?
0
8481
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8400
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8672
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6234
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.