473,686 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3244
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<stri ng>' 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<strin g> 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\k au\cplusplus\la b4_c++\start.cp p(10): error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10): error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10): error
C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@ verizon.net> skrev i meddelandet
news:Nlrhe.3970 $x85.934@trnddc 01...
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<stri ng>' 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<strin g> 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\k au\cplusplus\la b4_c++\start.cp p(10): error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10): error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10): error
C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@ verizon.net> skrev i meddelandet
news:Nlrhe.3970 $x85.934@trnddc 01...
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
declaratio n 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<st ring>' 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<strin g> 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@trnddc0 8...
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\k au\cplusplus\la b4_c++\start.cp p(10):
error C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10):
error C2059: syntax error : '>'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10):
error C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@ verizon.net> skrev i meddelandet
news:Nlrhe.3970 $x85.934@trnddc 01...
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
declarati on 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<s tring>' 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<strin g> 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\k au\cplusplus\la b4_c++\start.cp p(10): error
C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10): error
C2059: syntax error : '>'

c:\Documents and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(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@trnddc0 8...
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:\Documen ts and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10):
error C2947: expecting '>' to terminate template-argument-list, found '<'

c:\Documen ts and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10):
error C2059: syntax error : '>'

c:\Documen ts and Settings\Tony\k au\cplusplus\la b4_c++\start.cp p(10):
error C2143: syntax error : missing ';' before '>'

//Tony

"Larry I Smith" <la***********@ verizon.net> skrev i meddelandet
news:Nlrhe.3 970$x85.934@trn ddc01...
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
>declaratio n 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<strin g> mylist;

to

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

Note that classes to be used in STL
container s 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
2321
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 and check it against several regular expressions and do something once I find a match. For example, in perl ... if ($line =~ /struct {/) { do something } elsif ($line =~ /typedef struct {/) { do something else
2
2185
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 nachdem, ob man vor oder hinter der Toilettentüre ist. www.heimkacken.de
1
2959
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 background-color I want to have an repeating pattern. I'm able to get the either the fixed image working or the repeating pattern, but not both together. In Short: I'm trying to get an image like in
0
2167
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 Body object contains one primitive datatype int. The Body instance is created in the constructor for Handle. In main I instansiate some Handle object and use the STL function push_front to push these object into the list.
25
2954
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 String Dim doc As New XmlDocument() Dim myElem As XmlElement
12
1853
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 any match. My current approach is to look for matches in substrings with the escaped characters as boundaries between the substrings. However, then ^ and $ in the patterns are treated wrongly. (Although I use startpos and endpos parameters for...
2
35572
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 implementation so the two can vary independently. Handle classes usually contain a pointer to the object implementation. The Handle object is used rather than the implemented object. This leaves the implemented object free to change without affecting...
10
1418
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 appear in that text, is there an efficient way to do this? I thought about looping through the array of names, and doing an IndexOf or Regex match, but this method is slow. Then I thought about an array intersection, but this is problematic for...
0
8585
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7603
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.