How do you specify a reference to a pointer

Discussion in 'C++' started by jessica_boxer@yahoo.com, Jan 12, 2007.

  1. Guest

    I want to specify a reference to a pointer. I tried this syntax, and it
    didn't compile.

    void func(string s, (Type*)& t);

    Any thoughts?
     
    , Jan 12, 2007
    #1
    1. Advertising

  2. Andre Kostur Guest

    wrote in news:1168618970.244074.99080
    @l53g2000cwa.googlegroups.com:

    > I want to specify a reference to a pointer. I tried this syntax, and it
    > didn't compile.
    >
    > void func(string s, (Type*)& t);
    >
    > Any thoughts?
    >
    >



    void func(string s, Type *& t);


    I suspect that the compiler is attempting to take the address of t, then
    casting it to a Type* in your version.
     
    Andre Kostur, Jan 12, 2007
    #2
    1. Advertising

  3. Puppet_Sock Guest

    wrote:
    > I want to specify a reference to a pointer. I tried this syntax, and it
    > didn't compile.
    >
    > void func(string s, (Type*)& t);
    >
    > Any thoughts?


    The following seems to work for me.

    #include <string>

    class Type
    {
    public:
    int someData;
    };

    void func(std::string s, Type* & t);

    Socks
     
    Puppet_Sock, Jan 12, 2007
    #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. Tomas
    Replies:
    0
    Views:
    2,819
    Tomas
    Jan 21, 2004
  2. ezmiller
    Replies:
    1
    Views:
    698
    Richard Tobin
    Nov 26, 2005
  3. jacob navia

    How to specify a non-null pointer argument in C

    jacob navia, Jan 20, 2007, in forum: C Programming
    Replies:
    15
    Views:
    487
    jacob navia
    Jan 21, 2007
  4. Matthew
    Replies:
    3
    Views:
    360
    Matthew
    Feb 8, 2009
  5. A
    Replies:
    7
    Views:
    639
Loading...

Share This Page