C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 300,509 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,912 people online right now. Registration is fast and FREE... Join Now!




About vector<CType>::clear()

 

About vector<CType>::clear()

hajimeml

3 Jul, 2009 - 04:02 PM
Post #1

New D.I.C Head
*

Joined: 2 Jul, 2009
Posts: 4

Hello. I am trying to understand the following code. When the CTB<CType>::Initialize() member function is called, what object of type vector<CType> is going to have all the items removed? I am not sure why the Initialize function has no argument to specifically tells the clear() function which list to clear. Any ideas? Thanks.

template< class CType >
void CTB<CType>::Initialize(void)
{
vector<CType> ::clear();
}

User is offlineProfile CardPM
+Quote Post


perfectly.insane

RE: About Vector<CType>::clear()

5 Jul, 2009 - 01:23 PM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Mar, 2008
Posts: 635



Thanked: 62 times
Dream Kudos: 25
Expert In: C/C++

My Contributions
QUOTE(hajimeml @ 3 Jul, 2009 - 07:02 PM) *

Hello. I am trying to understand the following code. When the CTB<CType>::Initialize() member function is called, what object of type vector<CType> is going to have all the items removed? I am not sure why the Initialize function has no argument to specifically tells the clear() function which list to clear. Any ideas? Thanks.

template< class CType >
void CTB<CType>::Initialize(void)
{
vector<CType> ::clear();
}



If clear is not a static method of the vector template, then CTB<CType> must inherit vector<CType> in order for this to work. In other words, CTB<CType> is a vector<CType>, as opposed to CTB<CType> has a vector<CType> member.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/8/09 05:10AM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month