Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > too many typedefs

Reply
Thread Tools

too many typedefs

 
 
cppaddict
Guest
Posts: n/a
 
      06-19-2004
Hi,

I currently have a class in which I use all of the following a number
of times (nb: Point is custom class):

std::vector<Point>
std::vector<Point>&
const std::vector<Point>
const std::vector<Point>&

It would make things cleaner if I could use typedefs:

typedef std::vector<Point> Points

However, after making that declaration, I get warnings or errors if I
try things like this:

const Points&
Points&
....etc...

Does that mean I have to make a seperate typedef for each of the four
types generated by using the const and & symbols together with the
original type? If not, what can I do?

Thanks,
cpp
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-19-2004
"cppaddict" <(E-Mail Removed)> wrote...
> I currently have a class in which I use all of the following a number
> of times (nb: Point is custom class):
>
> std::vector<Point>
> std::vector<Point>&
> const std::vector<Point>
> const std::vector<Point>&
>
> It would make things cleaner if I could use typedefs:
>
> typedef std::vector<Point> Points
>
> However, after making that declaration, I get warnings or errors if I
> try things like this:
>
> const Points&
> Points&
> ...etc...
>
> Does that mean I have to make a seperate typedef for each of the four
> types generated by using the const and & symbols together with the
> original type? If not, what can I do?


Is that your first day here? Post your code.

Here is mine, and it compiles just fine:

#include <vector>
class Point {};
class FullOfTypedefs {
typedef std::vector<Point> PointVector;

PointVector regular_vector;
PointVector const const_vector;
PointVector & ref_to_reg_vector;
PointVector const & ref_to_const_vector;
public:
FullOfTypedefs() : ref_to_reg_vector(regular_vector)
, ref_to_const_vector(const_vector) {}
};

int main() {
FullOfTypedefs justToSeeIfICanInstantiateIt;
}


Victor


 
Reply With Quote
 
 
 
 
cppaddict
Guest
Posts: n/a
 
      06-19-2004

>Is that your first day here? Post your code.
>
>Here is mine, and it compiles just fine:


Sorry, Victor, you are right. The error was coming from something
else...

cpp
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Working through many typedefs pauldepstein@att.net C++ 1 07-04-2008 02:41 AM
How many warnings is too many? Rhino Java 33 12-22-2005 09:39 PM
How many threads are too many? rbt Python 1 06-11-2005 11:03 PM
How many threads is too many? peelman Java 12 01-15-2005 07:37 AM
Too many (small) vs. too large linked script files in a document... Dag Sunde Javascript 4 12-16-2004 11:38 PM



Advertisments