---
title: "Problem med templates och list"
type: "forum-thread"
url: "https://www.webforum.nu/amne/c-cpp/121058-problem-med-templates-och-list"
topic: "C/C++"
topic_url: "https://www.webforum.nu/amne/c-cpp"
author: "Viktor"
published: "2005-01-25T22:16:01.000Z"
updated: "2005-01-25T22:16:01.000Z"
replies: 0
views: 307
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/c-cpp/121058-problem-med-templates-och-list"
---

# Problem med templates och list

## #1 — Viktor, 2005-01-25T22:16Z

Jag har en lista som jag vill spara mina egna smarta pekare till klassen CActionBase i, såhär ser koden ut,

```
#include "screenobject.hpp"
#include "vgptr.hpp"
#include "actionbase.hpp"
#include "actionhelp.hpp"

#include <list>
#include <algorithm>
#include <iterator>
#include <functional>

namespace vwf
{
	class CActive : public CScreenObject
	{
	private:
		void Handle(CVGPtr<CActionBase> action, Event event);
	protected:
		CActive(void);

		list<CVGPtr<CActionBase> > m_Actions;
		list<CVGPtr<CActionBase> >::iterator m_ActionIter;
	public:
		static CVGPtr<CActive> create();

		virtual bool HandleEvent(Event event, CVGPtr<CScreenObject> scrObj);
		virtual void AddAction(CVGPtr<CActionBase> action);
		virtual void RemoveAction(CVGPtr<CActionBase> action);

		virtual ~CActive(void);
	};
}
```

och när jag försöker kompilera koden får jag följande fel (gcc  3.4.2),

> In file included from src/active.cpp:1:
> /home/viktor/dev/dsv/cpp/vwf/framework/include/active.hpp:22: error: ISO C++ forbids declaration of \`list' with no type
> /home/viktor/dev/dsv/cpp/vwf/framework/include/active.hpp:22: error: expected \`;' before '\<' token
> /home/viktor/dev/dsv/cpp/vwf/framework/include/active.hpp:23: error: ISO C++ forbids declaration of \`list' with no type
> /home/viktor/dev/dsv/cpp/vwf/framework/include/active.hpp:23: error: expected \`;' before '\<' token

Observera att den inte klagar på raden

```
void Handle(CVGPtr<CActionBase> action, Event event);
```

som använder samma typ av CVGPtr.

/Viktor

Permalänk: https://www.webforum.nu/p/121058

---

Tråden på webben: https://www.webforum.nu/amne/c-cpp/121058-problem-med-templates-och-list
