about intersection in the vector....any idea?

This is a discussion on about intersection in the vector....any idea? within the C++ Programming forums, part of the General Programming Boards category; hi everyone, can someone please give me some idea on this kinda function? being thinking whole day and dont know ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    141

    about intersection in the vector....any idea?

    hi everyone, can someone please give me some idea on this kinda function?

    being thinking whole day and dont know what it means...

    // intersection of this set with another
    // Pre: a StringSet object
    // Post: returns a new StringSet which is the intersection
    // of this with otherset, ie. only the items common to both StringSets
    StringSet StringSet::set_intersection(StringSet otherset)
    {


    }

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    (1)StringSet (2)StringSet(3)::(4)set_intersection((5)StringSet otherset)

    This is a function defined as member of a class.

    • (1) The function will return an object of type StringSet.
    • (2) The function is defined as a member of the StringSet class.
    • (3) The scope operator (:: ) serves to establish in which scope should this function be defined. On this case, it is the StringSet scope
    • (4) The function name.
    • (5) It's parameter. It accepts as parameter a StringSet object that it will call otherset.


    To better understand how to define function members of classes, read about classes on some good tutorial like:

    http://www.cplusplus.com/doc/tutorial/classes.html
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    141
    yap, thank you for that. but i mean code idea not definition sample... thank you

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    What's to think about?
    Do you know what a set is - look it up at mathworld.

    Elements which appear in both are the intersection, so just a loop searching for each one.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. project idea ???
    By gemini_shooter in forum C Programming
    Replies: 2
    Last Post: 06-09-2005, 09:56 AM
  2. Have an idea?
    By B0bDole in forum Projects and Job Recruitment
    Replies: 46
    Last Post: 01-13-2005, 02:25 PM
  3. A little problem about an idea, help please
    By louis_mine in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2004, 09:52 PM
  4. totally screwed up idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-17-2001, 12:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21