can someone help me with some c++ tonite?

Discussion in 'OT Technology' started by Furner, Nov 9, 2006.

  1. Furner

    Furner New Member

    Joined:
    Jan 7, 2003
    Messages:
    7,584
    Likes Received:
    0
    Location:
    Grand Rapids, MI
    I am trying to get a program working, our professor gives us code but sometimes its a little rough and needs work.
    well i am declaring a function as follows
    bool solutionFound(set::const_iterator [])
    and the compiler says that dosnt follow the template. if i knew c++ better i could probably figure it out, but i dont know, or really care.
    if someone could smooth that line over so it works, i could appreciate it.
    ps. i know i need to know what type of set of const_iterators it is, but i dont. maybe its still fixable? :hs:
     
  2. Darketernal

    Darketernal Watch: Aria The Origination =)

    Joined:
    Oct 8, 2002
    Messages:
    10,498
    Likes Received:
    3
    Location:
    Care,for all is like a bonsai tree
  3. Coottie

    Coottie BOOMER......SOONER OT Supporter

    Joined:
    Jun 6, 2006
    Messages:
    32,407
    Likes Received:
    0
    Location:
    OKC
    I'm assuming your function is inside of a class?? If so your syntax should be more like this:
    <return_type> <class_name>::<function_name>(<parameter_type> <param1_name>, ...)

    So if your return type is bool, class name is Student, function name is solutionFound and parameter is an integer representing the student number here is what you'd have:
    bool Student::solutionFound(int student_num) {
    //your code here. since you are inside a class, you have access to the private variables here.
    }

    Does this help or am I not understanding your issue?
     
  4. Furner

    Furner New Member

    Joined:
    Jan 7, 2003
    Messages:
    7,584
    Likes Received:
    0
    Location:
    Grand Rapids, MI
    i dont think thats the same. this isnt really a c++ class, its a data structures class, we are producing a long, worthless sudoku solver to demonstrate our understanding of the STL.
    i just hacked together a bunch of shit that will probably be ok for the prof. it works at least.
    now i need to figure out how to check the solutions "his way"
     
  5. athan

    athan Guest

    I would suggest reading the book for the class. all the data structures crap I learned from taking that class has long been forgotten.
     
  6. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    You need to declare the template type, it should look something like

    Code:
    bool solutionFound(set<int>::const_iterator [])
    
    or use a typedef somewhere to declare set<int> a new type to avoid typing it frequently.
     

Share This Page