By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

typedef not being seen

P: n/a

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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.