473,385 Members | 1,409 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,385 software developers and data experts.

another visibility problem

Hi,

for this code:

template <typename content, typename ptr, typename ref>
class tree_iterator
: public std::iterator<std::forward_iterator_tag, content, std::ptrdiff_t,
ptr, ref>
{
node<content> *node_;
public:
reference operator*() const {return node_->value;}
pointer operator->() const {return &(node_->value);}
};

gcc says

error: ISO C++ forbids declaration of `reference' with no type
error: expected `;' before "operator"
error: expected `;' before "pointer"
error: ISO C++ forbids declaration of `pointer' with no type
error: expected `;' before "operator"
error: expected `;' before '}' token

but as far as I understand, this is the intended usage of std::iterator,
and those names should be visible. Throwing using declarations at the problem
doesn't seems to help either. Any ideas what am I doing wrong?

Thx

ImRe
Nov 24 '05 #1
2 1429
Imre Palik wrote:
Hi,

for this code:

template <typename content, typename ptr, typename ref>
class tree_iterator
: public std::iterator<std::forward_iterator_tag, content, std::ptrdiff_t,
ptr, ref>
{
node<content> *node_;
public:
reference operator*() const {return node_->value;}
pointer operator->() const {return &(node_->value);}
};

gcc says

error: ISO C++ forbids declaration of `reference' with no type
error: expected `;' before "operator"
error: expected `;' before "pointer"
error: ISO C++ forbids declaration of `pointer' with no type
error: expected `;' before "operator"
error: expected `;' before '}' token

but as far as I understand, this is the intended usage of std::iterator,
and those names should be visible. Throwing using declarations at the problem
doesn't seems to help either. Any ideas what am I doing wrong?

Thx

ImRe

You haven't shown the template for node so I took the liberty of
guessing. Anyway with gcc 3.3 the following appears to compile with no
warnings or errors.

template <typename T>
class node
{
public:
T value;
};

template <typename content, typename ptr, typename ref>
class tree_iterator
: public std::iterator<std::forward_iterator_tag, content,
std::ptrdiff_t,
ptr, ref>
{
node<content> *node_;
public:
typename tree_iterator<content,ptr,ref>::reference operator*()
const {return node_->value;}
typename tree_iterator<content,ptr,ref>::pointer operator->() const
{return &(node_->value);}
};

Hope this helps

JB
Nov 24 '05 #2

Imre Palik wrote:
Hi,

for this code:

template <typename content, typename ptr, typename ref>
class tree_iterator
: public std::iterator<std::forward_iterator_tag, content, std::ptrdiff_t,
ptr, ref>
{
node<content> *node_;
public:
reference operator*() const {return node_->value;}
pointer operator->() const {return &(node_->value);}
};

gcc says

error: ISO C++ forbids declaration of `reference' with no type
error: expected `;' before "operator"
error: expected `;' before "pointer"
error: ISO C++ forbids declaration of `pointer' with no type
error: expected `;' before "operator"
error: expected `;' before '}' token

but as far as I understand, this is the intended usage of std::iterator,
and those names should be visible. Throwing using declarations at the problem
doesn't seems to help either. Any ideas what am I doing wrong?


This has beed discussed many times here and elsewhere.

reference and pointer are typedefs from a template argument dependent
base class. To use them you need to fully qualify them otherwise they
will never be found by a compiler. Add the following typedefs to your
derived class:

typedef std::iterator<std::forward_iterator_tag, content,
std::ptrdiff_t, ptr, ref> base;
typedef typename base::reference reference;
typedef typename base::pointer pointer;

Nov 24 '05 #3

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

Similar topics

3
by: Vernon Peppers | last post by:
I know that there are already a bunch of these requests in the newsgroup, but no one has answered one that would help me. I have a site that uses Javascript, http://www.namemaker.com, and one of...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
11
by: Ian Collins | last post by:
I've been scratching my head over this one, I have a simple menu, <div id="linksDiv"> <ul id="viewMenu" class="hidden"> <li> <a href="customer.html">Customer</a> </li> <li> <a...
1
by: giangiammy | last post by:
hi all, switching from firefox 1.07 to 1.5.0.3 (linux version) I got errors on a javascript page: error in parsing value for property 'visibility'. Declaration dropped. the proble should be...
11
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
7
by: Nik | last post by:
I'm trying to combine css-popups with an images-in-inline-lists gallery. The problem I see with http://www.niksally.f2s.com/upload/gallery/gallery.html is that the images jog when the mouse...
2
by: Steve JORDI | last post by:
Hi, I have a strange problem using Internet Explorer. My page has a table included in a <DIV> I have a checkbox that shows the div when checked and hides it when unchecked. var division =...
8
by: gerry | last post by:
The PagerSettings.Visible property is not being handled properly by the GridView control. The value assigned to this property is not applied until after a postback. Simplest test : .aspx...
1
by: The Menace | last post by:
I have a problem that I've been trying to figure out. I have several controls on the page and depending on the selection on the drop down list, the visibility is set to control to true (set to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.