473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

STL and Handle body pattern

Hello!!

Assume I have a handle body pattern with classes called Handle and Body.

In the Body class I store one int value for example 7 or some other integer
value.
In the Handle class I have a pointer to the Body class.

If a want to create a STL container of List with the following
declaration List <Handle <Body> > list
The list contains nodes with handles that contains a pointer to Body.

In the constructor of class Handle I create dynamically an object of class
Body so I have a pointer to a created Body object in class Handle.
So in main I instansiate an object of class Handle

Can somebode give me a hint how do I write if I want to store this Handle
object called handle in the STL created List called list. I have to use some
STL operation or Algoritm.
//Tony
Jul 23 '05 #1
7 3208
Tony Johansson wrote:
Hello!!

Assume I have a handle body pattern with classes called Handle and Body.

In the Body class I store one int value for example 7 or some other integer
value.
In the Handle class I have a pointer to the Body class.

If a want to create a STL container of List with the following
declaration List <Handle <Body> > list
The list contains nodes with handles that contains a pointer to Body.

In the constructor of class Handle I create dynamically an object of class
Body so I have a pointer to a created Body object in class Handle.
So in main I instansiate an object of class Handle

Can somebode give me a hint how do I write if I want to store this Handle
object called handle in the STL created List called list. I have to use some
STL operation or Algoritm.
//Tony


Read the two web pages below. In the examples for
'std::list<string>' in section 12.3.2 just replace
'string' with your 'Handle' class to get a basic
idea of what you must do.

For example, change:

std::list<string> mylist;

to

std::list< Handle< Body > > mylist;

Note that classes to be used in STL
containers must meet certain requirements (have a
copy constructor, an operator<(), etc); see the
docs for details.

http://www.icce.rug.nl/documents/cpl...lusplus12.html
http://www.icce.rug.nl/documents/cpl...lusplus17.html

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #2
Hello again!!

Have you any idea why I can't declare in this way
list <Handle<Body> > myList;

I get the following compilation error,
c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:Nlrhe.3970$x85.934@trnddc01...
Tony Johansson wrote:
Hello!!

Assume I have a handle body pattern with classes called Handle and Body.

In the Body class I store one int value for example 7 or some other
integer value.
In the Handle class I have a pointer to the Body class.

If a want to create a STL container of List with the following
declaration List <Handle <Body> > list
The list contains nodes with handles that contains a pointer to Body.

In the constructor of class Handle I create dynamically an object of
class Body so I have a pointer to a created Body object in class Handle.
So in main I instansiate an object of class Handle

Can somebode give me a hint how do I write if I want to store this Handle
object called handle in the STL created List called list. I have to use
some STL operation or Algoritm.
//Tony


Read the two web pages below. In the examples for
'std::list<string>' in section 12.3.2 just replace
'string' with your 'Handle' class to get a basic
idea of what you must do.

For example, change:

std::list<string> mylist;

to

std::list< Handle< Body > > mylist;

Note that classes to be used in STL
containers must meet certain requirements (have a
copy constructor, an operator<(), etc); see the
docs for details.

http://www.icce.rug.nl/documents/cpl...lusplus12.html
http://www.icce.rug.nl/documents/cpl...lusplus17.html

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.

Jul 23 '05 #3
Tony Johansson wrote:
Hello again!!

Have you any idea why I can't declare in this way
list <Handle<Body> > myList;

I get the following compilation error,
c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:Nlrhe.3970$x85.934@trnddc01...
Tony Johansson wrote:
Hello!!

Assume I have a handle body pattern with classes called Handle and Body.

In the Body class I store one int value for example 7 or some other
integer value.
In the Handle class I have a pointer to the Body class.

If a want to create a STL container of List with the following
declaration List <Handle <Body> > list
The list contains nodes with handles that contains a pointer to Body.

In the constructor of class Handle I create dynamically an object of
class Body so I have a pointer to a created Body object in class Handle.
So in main I instansiate an object of class Handle

Can somebode give me a hint how do I write if I want to store this Handle
object called handle in the STL created List called list. I have to use
some STL operation or Algoritm.
//Tony


Read the two web pages below. In the examples for
'std::list<string>' in section 12.3.2 just replace
'string' with your 'Handle' class to get a basic
idea of what you must do.

For example, change:

std::list<string> mylist;

to

std::list< Handle< Body > > mylist;

Note that classes to be used in STL
containers must meet certain requirements (have a
copy constructor, an operator<(), etc); see the
docs for details.

http://www.icce.rug.nl/documents/cpl...lusplus12.html
http://www.icce.rug.nl/documents/cpl...lusplus17.html

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.



Please don't top-post.

Post a minimal code example that produces the problem,
including the minimal class def's for 'Handle' and 'Body'.

What compiler are you using?

Did you '#include<list>' ?

Does 'std::list< Handle< Body > > myList;' fix the problem?

Is 'Handle<Body>' defined prior to trying to use it in a 'list'?

Is either 'Handle' or 'Body' a reserved word (or already defined) by
your compiler, OS, or one of the libs in use?

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #4

"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:rLrhe.427$pb1.371@trnddc08...
Tony Johansson wrote:
Hello again!!

Have you any idea why I can't declare in this way
list <Handle<Body> > myList;

I get the following compilation error,
c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2059: syntax error : '>'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:Nlrhe.3970$x85.934@trnddc01...
Tony Johansson wrote:

Hello!!

Assume I have a handle body pattern with classes called Handle and Body.

In the Body class I store one int value for example 7 or some other
integer value.
In the Handle class I have a pointer to the Body class.

If a want to create a STL container of List with the following
declaration List <Handle <Body> > list
The list contains nodes with handles that contains a pointer to Body.

In the constructor of class Handle I create dynamically an object of
class Body so I have a pointer to a created Body object in class Handle.
So in main I instansiate an object of class Handle

Can somebode give me a hint how do I write if I want to store this
Handle object called handle in the STL created List called list. I have
to use some STL operation or Algoritm.
//Tony

Read the two web pages below. In the examples for
'std::list<string>' in section 12.3.2 just replace
'string' with your 'Handle' class to get a basic
idea of what you must do.

For example, change:

std::list<string> mylist;

to

std::list< Handle< Body > > mylist;

Note that classes to be used in STL
containers must meet certain requirements (have a
copy constructor, an operator<(), etc); see the
docs for details.

http://www.icce.rug.nl/documents/cpl...lusplus12.html
http://www.icce.rug.nl/documents/cpl...lusplus17.html

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.



Please don't top-post.

Post a minimal code example that produces the problem,
including the minimal class def's for 'Handle' and 'Body'.

What compiler are you using?

Did you '#include<list>' ?

Does 'std::list< Handle< Body > > myList;' fix the problem?

Is 'Handle<Body>' defined prior to trying to use it in a 'list'?

Is either 'Handle' or 'Body' a reserved word (or already defined) by
your compiler, OS, or one of the libs in use?

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.

Hello again!

Here is main with the declaration that cause the compile error.
I use Visual studio .NET

Have you any idea how the declaration statement should be defined.?
#include "body.h"
#include <list>
using namespace std;

int main()
{
list <Handle <Body> > myList;
return 0;
}

//Tony
Jul 23 '05 #5
Tony Johansson wrote:
Hello again!!

Have you any idea why I can't declare in this way
list <Handle<Body> > myList;
This "list" is "std::list" ?
I get the following compilation error,
c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) : error
C2143: syntax error : missing ';' before '>'

[snip]

a) Please do not top post.

b) Please delete comments that you do not refer to.

c) Show us your defintion of Handle. Are you sure it has been declared
as a template?
Best

Kai-Uwe Bux
Jul 23 '05 #6
Tony Johansson wrote:
"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:rLrhe.427$pb1.371@trnddc08...
Tony Johansson wrote:
Hello again!!

Have you any idea why I can't declare in this way
list <Handle<Body> > myList;

I get the following compilation error,
c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2059: syntax error : '>'

c:\Documents and Settings\Tony\kau\cplusplus\lab4_c++\start.cpp(10) :
error C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@verizon.net> skrev i meddelandet
news:Nlrhe.3970$x85.934@trnddc01...
Tony Johansson wrote:
>Hello!!
>
>Assume I have a handle body pattern with classes called Handle and Body.
>
>In the Body class I store one int value for example 7 or some other
>integer value.
>In the Handle class I have a pointer to the Body class.
>
>If a want to create a STL container of List with the following
>declaration List <Handle <Body> > list
>The list contains nodes with handles that contains a pointer to Body.
>
>In the constructor of class Handle I create dynamically an object of
>class Body so I have a pointer to a created Body object in class Handle.
>So in main I instansiate an object of class Handle
>
>Can somebode give me a hint how do I write if I want to store this
>Handle object called handle in the STL created List called list. I have
>to use some STL operation or Algoritm.
>
>
>//Tony

Read the two web pages below. In the examples for
'std::list<string>' in section 12.3.2 just replace
'string' with your 'Handle' class to get a basic
idea of what you must do.

For example, change:

std::list<string> mylist;

to

std::list< Handle< Body > > mylist;

Note that classes to be used in STL
containers must meet certain requirements (have a
copy constructor, an operator<(), etc); see the
docs for details.

http://www.icce.rug.nl/documents/cpl...lusplus12.html
http://www.icce.rug.nl/documents/cpl...lusplus17.html

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.

Please don't top-post.

Post a minimal code example that produces the problem,
including the minimal class def's for 'Handle' and 'Body'.

What compiler are you using?

Did you '#include<list>' ?

Does 'std::list< Handle< Body > > myList;' fix the problem?

Is 'Handle<Body>' defined prior to trying to use it in a 'list'?

Is either 'Handle' or 'Body' a reserved word (or already defined) by
your compiler, OS, or one of the libs in use?

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.


Hello again!

Here is main with the declaration that cause the compile error.
I use Visual studio .NET

Have you any idea how the declaration statement should be defined.?
#include "body.h"
#include <list>
using namespace std;

int main()
{
list <Handle <Body> > myList;
return 0;
}

//Tony


Please post the code for 'Handle' and 'Body'.
Is it in 'body.h'? Without that code we can
not tell you what might be wrong.

Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #7
> Hello again!

Here is main with the declaration that cause the compile error.
I use Visual studio .NET

Have you any idea how the declaration statement should be defined.?
#include "body.h"
#include <list>
using namespace std;

int main()
{
list <Handle <Body> > myList;
return 0;
}

//Tony


My bet:
You're missing the definition of the Handle template, and this screws up
the compiler because it doesn't know what Handle is, or differently put,
it doesn't expect Handle to be a generic type and such expects a closing
'>' after Handle.
(Of course it doesn't matter whether or not Handle is a generic, if you
don't provide its definition, it's an error).

--
Matthias Kaeppler
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matt Wette | last post by:
Over the last few years I have converted from Perl and Scheme to Python. There one task that I do often that is really slick in Perl but escapes me in Python. I read in a text line from a file...
2
by: Robert Blasius | last post by:
Hi there, I'm trying to realize a css with an fixed image in the upperleft and additionally a pattern which fills the whole body of the site. -- Eine Minute kann unterschiedlich lang sein, je...
1
by: Robert Blasius | last post by:
Hi there. sorry, for the first posting. I pressed the wrong button... Again. I`m trying to realize an css for the body-tag which contains an fixed image in the upperleft and instead of an...
0
by: Tony Johansson | last post by:
Hello! Here I have two classes these are called Handle and Body and a main. You have the class definition below. Some basic information. In the Handle class is there a pointer to the Body. Each...
25
by: MeNotHome | last post by:
I am automating the navigation of a website. When I reach the end, it changes to xml. So my axwebbrowser1 has a bunch of xml data in it. So here is what I am trying to do Dim xmlText As...
12
by: Torsten Bronger | last post by:
Hallöchen! I need some help with finding matches in a string that has some characters which are marked as escaped (in a separate list of indices). Escaped means that they must not be part of...
2
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
10
by: Brent | last post by:
I have a list of company names (say, IBM, Corning, General Motors, and another 5,000 of them). If I take a body of text, a news article, for instance, and I want to see which company names...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.