too many typedefs

Discussion in 'C++' started by cppaddict, Jun 19, 2004.

  1. cppaddict

    cppaddict Guest

    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
     
    cppaddict, Jun 19, 2004
    #1
    1. Advertising

  2. "cppaddict" <> 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
     
    Victor Bazarov, Jun 19, 2004
    #2
    1. Advertising

  3. cppaddict

    cppaddict Guest


    >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
     
    cppaddict, Jun 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peelman

    How many threads is too many?

    peelman, Jan 13, 2005, in forum: Java
    Replies:
    12
    Views:
    865
    Esmond Pitt
    Jan 15, 2005
  2. Rhino
    Replies:
    33
    Views:
    1,346
    Oliver Wong
    Dec 22, 2005
  3. rbt
    Replies:
    1
    Views:
    371
  4. How many roles is too many?

    , Jun 13, 2006, in forum: ASP .Net Security
    Replies:
    4
    Views:
    207
    Joe Kaplan \(MVP - ADSI\)
    Jun 18, 2006
  5. Dag Sunde
    Replies:
    4
    Views:
    376
Loading...

Share This Page