473,396 Members | 2,020 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,396 software developers and data experts.

typedef not being seen


Hello all,

I have included below a header file for a module I'm working on. Please
note the line marked "***** ERROR HERE *****". At this line, the type dl_t
is not being seen for some reason. Can anybody see why this is?

Thanks,
Dave
#ifndef DIRECTED_GRAPH_INCLUDED
#define DIRECTED_GRAPH_INCLUDED

#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <vector>

namespace directed_graph
{
// Template parameter T specifies the type of the values used to uniquely
// identify vertices.
template<typename T>
class directed_graph_t
{
public:
directed_graph_t();

// The only way this can fail is if the source or destination does
not
// exist. A request to add an already-existing edge is a no-op.
In
// the event of a failure, an exception will be thrown containing
the
// offending vertex ID.
void add_edge(const T &source_id, const T &destination_id);

// This will never fail. A request to add an already-existing
vertex
// is a no-op.
void add_vertex(const T &vertex_id);

void clear();

// For each vertex, determine all vertices reachable from that
vertex.
dl_t get_descendents(); // ***** ERROR HERE *****

std::vector<T> get_dfs_discovery_times();
std::vector<T> get_dfs_finish_times();

bool is_acyclic();

// This function will return a topological sort of the vertex set,
if
// possible. The only case when this can't be done is if the graph
is
// not acyclic. In this case, an exception will be thrown.
std::vector<T> topological_sort();

private:
// Disable copying and assignment.
directed_graph_t(const directed_graph_t &);
directed_graph_t &operator=(const directed_graph_t &);

enum vertex_color_t
{
WHITE,
GRAY,
BLACK
};

// Types related to the adjacency list representation of a graph
typedef std::map<T, std::set<T> > al_t;
typedef typename al_t::iterator al_iter_t;

// Types related to descendents of vertices (i.e. other reachable
// vertices)
typedef std::map<T, std::set<T> > dl_t;
typedef typename dl_t::iterator dl_iter_t;

// Types used to store the colors of vertices
typedef std::map<T, vertex_color_t> vc_t;
typedef typename vc_t::iterator vc_iter_t;

bool acyclic;
al_t adjacency_list;
std::vector<T> dfs_discovery_times;
std::vector<T> dfs_finish_times;
bool dfs_search_performed;
vc_t vertex_colors;

void dfs_visit(const T &vertex_id);
void perform_dfs_search();
};
}

// Include the definition of functions declared above.
#include "directed_graph.inl"

#endif
Jul 22 '05 #1
6 1886
Dave wrote:
Hello all,

I have included below a header file for a module I'm working on. Please
note the line marked "***** ERROR HERE *****". At this line, the type dl_t
is not being seen for some reason. Can anybody see why this is?


dl_t is supposed to come from where ?

Jul 22 '05 #2

"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bq********@dispatch.concentric.net...
Dave wrote:
Hello all,

I have included below a header file for a module I'm working on. Please
note the line marked "***** ERROR HERE *****". At this line, the type dl_t is not being seen for some reason. Can anybody see why this is?


dl_t is supposed to come from where ?


It's in the private section of the class definition. It's a typedef. It's
in there, but it's not necessarily easy to spot...

Oops, perhaps I just stumbled on something in answering you, but I still
don't think it solves my problem. Client code will need the type, so it
can't be private. But what I'm looking at now is *within( the class, so
that shouldn't matter. The private issue is a problem, but not *the*
problem I'm trying to track down now...
Jul 22 '05 #3
hi!
[...]
typedef std::map<T, std::set<T> > dl_t;
[...]

i suggest you put the typedefs somewhere _before_ you use the new names..

regards,
sev
Jul 22 '05 #4
Dave wrote:
"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bq********@dispatch.concentric.net...
Dave wrote:
Hello all,

I have included below a header file for a module I'm working on. Please
note the line marked "***** ERROR HERE *****". At this line, the type
dl_t
is not being seen for some reason. Can anybody see why this is?


dl_t is supposed to come from where ?

It's in the private section of the class definition. It's a typedef. It's
in there, but it's not necessarily easy to spot...

Oops, perhaps I just stumbled on something in answering you, but I still
don't think it solves my problem. Client code will need the type, so it
can't be private. But what I'm looking at now is *within( the class, so
that shouldn't matter. The private issue is a problem, but not *the*
problem I'm trying to track down now...


I didn't find it because typedef dl_t has to come *before* it's used.

When I did that, it compiled fine.

Jul 22 '05 #5
> I didn't find it because typedef dl_t has to come *before* it's used.

When I did that, it compiled fine.


OK, thanks. I clearly am missing some tidbits of knowledge on when a
declaration becomes visible. I always thought that anything in a class is
visibile anywhere in the class, even before it's declared. For example, the
program below is perfectly valid even though bar() calls something that
hasn't yet been seen at the point of the call. Nevertheless, I clearly have
some misconceptions. Could somebody please explain exactly what the rules
are with regard to visibility inside of a class for the different kinds of
entities that may be declared therein?

Thanks!

#include <iostream>

using namespace std;

class foo_t
{
public:
void bar() {impl();}

private:
void impl() {cout << "Got here!" << endl;}
};

int main()
{
foo_t f;

f.bar();
}

Jul 22 '05 #6
On Thu, 4 Dec 2003 19:26:34 -0700, "Dave" <be***********@yahoo.com>
wrote:
I didn't find it because typedef dl_t has to come *before* it's used.

When I did that, it compiled fine.


OK, thanks. I clearly am missing some tidbits of knowledge on when a
declaration becomes visible. I always thought that anything in a class is
visibile anywhere in the class, even before it's declared. For example, the
program below is perfectly valid even though bar() calls something that
hasn't yet been seen at the point of the call. Nevertheless, I clearly have
some misconceptions. Could somebody please explain exactly what the rules
are with regard to visibility inside of a class for the different kinds of
entities that may be declared therein?


Name lookup inside member function definitions checks the whole class
scope. Name lookup in member declarations only checks class scope up
to that point.

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #7

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

Similar topics

14
by: dreamcatcher | last post by:
I always have this idea that typedef a data type especially a structure is very convenient in coding, but my teacher insisted that I should use the full struct declaration and no further...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
4
by: foodic | last post by:
Hi all, I am new to C programming. I have seen in many Source files a declaration as follows, typedef void iamafresher(int x, int y); why they use typedef with function. Please help,
20
by: Binary | last post by:
Hi, With keyword struct, we can simply do forward declare by: struct struct_a; but if we typedef it: typdef struct struct_a struct_a_t;
4
by: Fei Liu | last post by:
Hello, this is a follow-up question I had about typedef usage in Gianni Mariani's thread: news://213.88.137.53:119/46198ecf$0$13145$5a62ac22@per-qv1-newsreader-01.iinet.net.au int foo(int A, int...
5
by: Jess | last post by:
Hello, I think the syntax of typedef is typedef existing-type new-type However, I've seen a statement typedef string stringarray;
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
1
by: sophia | last post by:
Dear all, the following are the differences b/w #define and typedef ,which i have seen in Peter van der lindens book. is there any other difference between thes two ? The right way to...
16
by: mdh | last post by:
A quick ? :-) question about Typedefs. There is a very brief discussion about this in K&R ( p146). Googling this group, there is a surprising dearth of questions about these. From one of the...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.