Click here to Skip to main content
16,015,629 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralProblem using CResizableFormView with MSFLEXGRID control! Pin
Nguyễn Thiện Nhẫn4-Jun-04 18:33
Nguyễn Thiện Nhẫn4-Jun-04 18:33 
Generalquery reg STL maps Pin
Member 11501763-Jun-04 23:32
Member 11501763-Jun-04 23:32 
GeneralRe: query reg STL maps Pin
Paul Ranson4-Jun-04 3:02
Paul Ranson4-Jun-04 3:02 
GeneralRe: query reg STL maps Pin
Member 11501764-Jun-04 3:19
Member 11501764-Jun-04 3:19 
GeneralRe: query reg STL maps Pin
sas22224-Jun-04 4:47
sas22224-Jun-04 4:47 
GeneralRe: query reg STL maps Pin
sas22224-Jun-04 5:26
sas22224-Jun-04 5:26 
GeneralRe: query reg STL maps Pin
sas22224-Jun-04 5:32
sas22224-Jun-04 5:32 
GeneralRe: query reg STL maps Pin
Paul Ranson4-Jun-04 5:38
Paul Ranson4-Jun-04 5:38 
Does this help?

#include <iostream>
#include <map>

class ClassOne
{
public :
    int age;
    int sal;
} ;

typedef std::map<int, ClassOne> Map ;

int main()
{
    Map theMap;
    Map::iterator theIterator;

    for ( int i = 0; i < 1000; ++i )
    {
        ClassOne one ;
        one.age = 40 ;
        one.sal = 1000 ;
        theMap.insert ( Map::value_type ( i, one )) ;
    }

    theIterator = theMap.find(0);

    if ( theIterator != theMap.end ())
    {
        std::cout << "The index " << (*theIterator).first << std::endl ;
        std::cout << "The class, age = " << (*theIterator).second.age << ", sal = " << (*theIterator).second.sal << std::endl ;
    }

    return 0;
}


There are other ways to manage insertion, for instance,
>#include <iostream>
#include <map>

class ClassTwo
{
private :
    int age;
    int sal;
public :
    ClassTwo () : age ( 0 ), sal ( 0 )
    {
    }
    void Set ( int a, int s )
    {
        age = a ;
        sal = s ;
    }
    int Age () const
    {
        return age ;
    }
    int Sal () const
    {
        return sal ;
    }
} ;

typedef std::map<int, ClassTwo> Map ;

int _tmain(int argc, _TCHAR* argv[])
{
    Map theMap;
    Map::iterator theIterator;

    for ( int i = 0; i < 1000; ++i )
    {
        std::pair<Map::iterator,bool> itp = theMap.insert ( Map::value_type ( i, ClassTwo ())) ;
        if ( itp.second )
        {
            theIterator = itp.first ;
            (*theIterator).second.Set ( 40, 1000 ) ;
        }            
    }

    theIterator = theMap.find(0);

    if ( theIterator != theMap.end ())
    {
        std::cout << "The index " << (*theIterator).first << std::endl ;
        std::cout << "The class, age = " << (*theIterator).second.age << ", sal = " << (*theIterator).second.sal << std::endl ;
    }

    return 0;
}


Paul
QuestionAnybody tell me how to use IStream correctly? Pin
max_xiayi3-Jun-04 18:59
max_xiayi3-Jun-04 18:59 
AnswerRe: Anybody tell me how to use IStream correctly? Pin
Todd Smith4-Jun-04 13:22
Todd Smith4-Jun-04 13:22 
AnswerRe: Anybody tell me how to use IStream correctly? Pin
f649-Jun-04 6:31
f649-Jun-04 6:31 
GeneralBase Class Undefined Pin
TFrancis3-Jun-04 7:56
TFrancis3-Jun-04 7:56 
QuestionHow to call methods of an appobject directly? Pin
Roozbeh692-Jun-04 4:01
professionalRoozbeh692-Jun-04 4:01 
QuestionWhat a sh##t!!! Pin
El'Cachubrey2-Jun-04 2:25
El'Cachubrey2-Jun-04 2:25 
AnswerRe: What a sh##t!!! Pin
sas22222-Jun-04 3:55
sas22222-Jun-04 3:55 
Generalshell programming Pin
sas22221-Jun-04 8:56
sas22221-Jun-04 8:56 
GeneralRe: shell programming Pin
Prakash Nadar2-Jun-04 7:10
Prakash Nadar2-Jun-04 7:10 
GeneralRe: shell programming Pin
sas22222-Jun-04 7:33
sas22222-Jun-04 7:33 
GeneralRe: shell programming Pin
Prakash Nadar2-Jun-04 15:49
Prakash Nadar2-Jun-04 15:49 
GeneralRe: shell programming Pin
sas22223-Jun-04 6:07
sas22223-Jun-04 6:07 
GeneralDebugging ATL control Pin
roel_1-Jun-04 5:01
roel_1-Jun-04 5:01 
GeneralRe: Debugging ATL control Pin
roel_1-Jun-04 5:15
roel_1-Jun-04 5:15 
GeneralRe: Debugging ATL control Pin
Jörgen Sigvardsson1-Jun-04 8:49
Jörgen Sigvardsson1-Jun-04 8:49 
GeneralRe: Debugging ATL control Pin
roel_2-Jun-04 4:26
roel_2-Jun-04 4:26 
GeneralRe: Debugging ATL control Pin
_Magnus_2-Jun-04 2:05
_Magnus_2-Jun-04 2:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.