Article View: pl.comp.objects
Article #16134Typ należący do parametru template'a (czyli STL w parametrze)
From: lrem
Date: Mon, 09 Apr 2007 14:32
Date: Mon, 09 Apr 2007 14:32
23 lines
1620 bytes
1620 bytes
Witam po raz pierwszy grupę.
Tak z głupia frant postanowiłem opanować pisanie tempalate'ów w c++.
Popełniłem coś takiego:
#v+
template <class T>
void dump (const T &c)
{
for(T::iterator it = c.begin(); it!=c.end(); it++)
cerr << *it << ' ';
cerr << '\n';
}
#v-
Kiedy jednak próbuję to skompilować, z przeznaczeniem dla STL-owego
vectora, to widzę taki ładny komunikat:
#v+
symaxis.cpp:82: error: expected `;' before 'it'
symaxis.cpp:82: error: 'it' was not declared in this scope
#v-
Zamiana na /c.iterator it/ oczywiście też nic nie daje. Tak więc, jak to
zrobić poprawnie na szablonach?
Z góry dziękuję za odpowiedzi
Technical Details
Message-ID:
<slrnf1kjcu.ave.lrem@lrem.maxnet>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.tpinternet.pl!nemesis.news.tpi.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.tpinternet.pl!nemesis.news.tpi.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: lrem@lrem.maxnet Newsgroups: pl.comp.objects Subject: Typ należący do parametru template'a (czyli STL w parametrze) Date: Mon, 9 Apr 2007 14:32:55 +0000 (UTC) Organization: tp.internet - http://www.tpi.pl/ Lines: 23 Message-ID: <slrnf1kjcu.ave.lrem@lrem.maxnet> NNTP-Posting-Host: host-ip38-174.crowley.pl Mime-Version: 1.0 X-Trace: nemesis.news.tpi.pl 1176129175 28154 62.111.174.38 (9 Apr 2007 14:32:55 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Mon, 9 Apr 2007 14:32:55 +0000 (UTC) X-stopkeylogger: don't use broken software X-Posting-License: http://ppl.7thguard.net/PPL X-Homesite: http://lrem.net/ User-Agent: slrn/0.9.8.1 (Linux) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit