Click here to Skip to main content
15,924,196 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: SysTreeView32 and WTL Pin
The Arabundi2-Mar-04 11:01
The Arabundi2-Mar-04 11:01 
GeneralHi,atltypes.h Pin
Martin Walker2-Mar-04 5:34
Martin Walker2-Mar-04 5:34 
GeneralRe: Hi,atltypes.h Pin
Steve S2-Mar-04 6:26
Steve S2-Mar-04 6:26 
GeneralRe: Hi,atltypes.h Pin
Martin Walker2-Mar-04 7:50
Martin Walker2-Mar-04 7:50 
Questionhow to overload operator [] Pin
skpanda1-Mar-04 1:12
skpanda1-Mar-04 1:12 
AnswerRe: how to overload operator [] Pin
Michael Dunn1-Mar-04 9:16
sitebuilderMichael Dunn1-Mar-04 9:16 
GeneralRe: how to overload operator [] Pin
skpanda1-Mar-04 19:01
skpanda1-Mar-04 19:01 
GeneralRe: how to overload operator [] Pin
Jonas Larsson2-Mar-04 2:10
Jonas Larsson2-Mar-04 2:10 
Im assuming that m_lstrComputers is a std::list < std::string >

In that case, your error is that std::list< T > does not have an operator[], which is logical since it does not support random access iterators. You will have to walk your way to idx either from .begin() or .end().

#include < string >
#include < iostream > 
#include < list >
using namespace std;

class c
{
    list< string > l_;
public:
    c()
    {
        l_.push_back("test");
        l_.push_back("me");
    }

    string operator [] (unsigned int i) 
    {
        list< string >::iterator it = l_.begin();
        while (i-- != 0)
            it++;
        return *it;
    }
};

int main()
{
    c c;
    cout << c[0] << endl;
    return 0;
}


---

“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
GeneralRe: how to overload operator [] Pin
Nemanja Trifunovic2-Mar-04 6:15
Nemanja Trifunovic2-Mar-04 6:15 
GeneralRe: how to overload operator [] Pin
Jonas Larsson2-Mar-04 7:23
Jonas Larsson2-Mar-04 7:23 
GeneralASP.NET web Application not releasing ATL Component Pin
Anuj Mishra29-Feb-04 18:32
Anuj Mishra29-Feb-04 18:32 
GeneralRe: ASP.NET web Application not releasing ATL Component Pin
ian mariano29-Feb-04 20:38
ian mariano29-Feb-04 20:38 
GeneralRe: About the number of item of WTL CTreeViewCtrl Pin
Tim Smith29-Feb-04 14:11
Tim Smith29-Feb-04 14:11 
GeneralRe: About the number of item of WTL CTreeViewCtrl Pin
freehawk1-Mar-04 22:09
freehawk1-Mar-04 22:09 
QuestionHello World in gcc? Pin
Theofilactos Botaniaths27-Feb-04 5:08
Theofilactos Botaniaths27-Feb-04 5:08 
AnswerRe: Hello World in gcc? Pin
Steve S27-Feb-04 5:53
Steve S27-Feb-04 5:53 
GeneralRe: Hello World in gcc? Pin
Theofilactos Botaniaths27-Feb-04 7:03
Theofilactos Botaniaths27-Feb-04 7:03 
AnswerRe: Hello World in gcc? Pin
Nemanja Trifunovic27-Feb-04 6:04
Nemanja Trifunovic27-Feb-04 6:04 
GeneralRe: Hello World in gcc? Pin
Theofilactos Botaniaths27-Feb-04 7:08
Theofilactos Botaniaths27-Feb-04 7:08 
GeneralRe: Hello World in gcc? Pin
Jörgen Sigvardsson27-Feb-04 22:32
Jörgen Sigvardsson27-Feb-04 22:32 
GeneralRe: Hello World in gcc? Pin
Theofilactos Botaniaths1-Mar-04 1:32
Theofilactos Botaniaths1-Mar-04 1:32 
GeneralAbout CString Pin
freehawk26-Feb-04 14:51
freehawk26-Feb-04 14:51 
GeneralRe: About CString Pin
Michael Dunn26-Feb-04 15:30
sitebuilderMichael Dunn26-Feb-04 15:30 
GeneralRe: About CString Pin
freehawk26-Feb-04 15:44
freehawk26-Feb-04 15:44 
GeneralRe: About CString Pin
Michael Dunn26-Feb-04 18:17
sitebuilderMichael Dunn26-Feb-04 18:17 

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.