User Profile

Collapse

Profile Sidebar

Collapse
danalovesc
danalovesc
Last Activity: Sep 19 '10, 04:27 PM
Joined: Sep 3 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • c++: How to transform a map iterator which point to pair into a “regular” pair pointe

    those are the maps:

    Code:
     multimap<SortKey,T> firstMap;
        multimap<SearchKey,pair<SortKey,T>*> secondMap;
    
    
        template <class T,class SortKey, class SearchKey> bool GarageDataBase<T,SortKey,SearchKey>::Add(T data,SortKey key1, SearchKey key2) 
        {
         multimap<SortKey,T>::iterator it;
         it=(firstMap.insert(pair<SortKey,T>(key1,data)));
    ...
    See more | Go to post

  • Strange Behevior when trying to create a Template containing maps

    Hi all, i'm new to Templates and when i tried to implement templates methods which needs to use a map (which is a member in private), the map can only do 3 things: insert, swap, and operator =. and i don't get the full functionality of map..

    Here's the code:

    Code:
    #ifndef __GARAGE_H_
    #define __GARAGE_H_
    #include <map>
    using namespace std;
    template <class T,class SortKey,
    ...
    See more | Go to post

  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    thnx alot, this works!
    See more | Go to post

    Leave a comment:


  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    well if only i knew where do i even modify a const here..

    anyway i think i'll just go with definind < operator

    thank you all!!

    if someone can still point what the problem is i'll be happy to hear!:)
    See more | Go to post

    Leave a comment:


  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    this is how it is written in the h file:
    static bool EmployeeComp (Employee *e1,Employee* e2) const;

    still gives the same error when i did:

    m_cityHallWorke rs->sort(CityHall: :EmployeeComp);

    Error 1 error C2272: 'EmployeeComp' : modifiers not allowed on static member functions
    See more | Go to post

    Leave a comment:


  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    and then i get:


    Error 1 error C2272: 'EmployeeComp' : modifiers not allowed on static member functions

    same code as before, just added static at the h file
    See more | Go to post

    Leave a comment:


  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    @ Banfa --> how do i turn it into static, should i just add
    "static" before the func decleration at cityhall.h?
    See more | Go to post

    Leave a comment:


  • danalovesc
    replied to Sorting STL list by custom comperator
    in C
    hype261 --> I will try defining < for my class, i was just wondering why doesn't it work, and what should be the syntax for it to work

    newb16-->
    when u do that u get:


    Error 2 error C2064: term does not evaluate to a function taking 2 arguments

    and it jumps a file called "xutility" where it show the error in it
    See more | Go to post

    Leave a comment:


  • danalovesc
    started a topic Sorting STL list by custom comperator
    in C

    Sorting STL list by custom comperator

    Hey guys, i looked at some sorting examples, and i thought i jsut had to build a comperator which returns bool, in order to keep my list sorted by that value.

    here's the relevent code:

    Code:
    bool CityHall::EmployeeComp (Employee *e1,Employee *e2) const
    {
    if (e1->GetID()<e2->GetID())
    	return true;
    return false;
    }
    
    char** CityHall::PrintAllWorkersByLastName() const
    {
    ...
    See more | Go to post
    Last edited by Banfa; Sep 3 '10, 01:06 PM. Reason: Added code tags
No activity results to display
Show More
Working...