473,756 Members | 3,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<typena me 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(cons t 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_discove ry_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_sor t();

private:
// Disable copying and assignment.
directed_graph_ t(const directed_graph_ t &);
directed_graph_ t &operator=(cons t 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_t imes;
std::vector<T> dfs_finish_time s;
bool dfs_search_perf ormed;
vc_t vertex_colors;

void dfs_visit(const T &vertex_id);
void perform_dfs_sea rch();
};
}

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

#endif
Jul 22 '05 #1
6 1911
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*******@mari ani.ws> wrote in message
news:bq******** @dispatch.conce ntric.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*******@mari ani.ws> wrote in message
news:bq******** @dispatch.conce ntric.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
4647
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 explanations, so I wonder is there any good using typedef ? and I also know that when a data type being typedefed become an abstract data type, so what exactly is an abstract data type, is it any good ? -- Posted via http://dbforums.com
5
41035
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 on the previous definition of typedef, I can't understand the next:
4
4465
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
3136
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
1717
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 * pA){ return 0; } int main(){ typedef int * pi; typedef int ii; int a = sizeof(foo(ii(), pi())); }
5
3510
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
4651
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 (*(*(*ptr2d_fptr)()))();
1
5225
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 think about typedef as being a complete encapsulated type - you can't add to it after you have declared it.
16
2781
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 threads, there is sound advice ( to me at any rate) not to hide pointers behind typedefs. So, may I ask the group when the use of typedefs really makes sense? Sorry if this is somewhat general, but there are no exercises ( not that I am asking for...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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
8713
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
6534
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
5142
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...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.