expected unqualified-id before "." token?

Discussion in 'C++' started by Thomas Barth, Jul 18, 2006.

  1. Thomas Barth

    Thomas Barth Guest

    Hi,
    I was wondering if someone had any insight to what I am doing wrong. I
    ve got a class with two methods that call static methods of another
    class. When compiling my sourcecodes I get the error `expected
    unqualified-id before "." token` for the two static function calls:

    ....
    void V1Drawing::drawLine (double x1, double y1, double x2, double y2) {
    DPOne.draw_a_line(x1, y1, x2, y2); ###error###
    }

    void V1Drawing::drawCircle (double x, double y, double r) {
    DPOne.draw_a_circle(x, y, r); ###error###
    }
    ....

    ---DPOne.h---
    #ifndef DP1_H_
    #define DP1_H_

    class DPOne {
    public:
    DPOne();
    virtual ~DPOne();

    static void draw_a_line (double x1, double y1, double x2, double y2);
    static void draw_a_circle (double x, double y, double r);
    };

    #endif /*DP1_H_*/
    ---/DPOne.h---


    ---DPOne.cpp---
    #include "DPOne.h"

    DPOne::DPOne() {
    }

    DPOne::~DPOne() {
    }

    void DPOne::draw_a_line(double x1, double y1, double x2, double y2) {
    ...
    }

    void DPOne::draw_a_circle(double x, double y, double r) {
    ...
    }
    ---/DPOne.cpp---


    I use gcc 4.0.3 on a Linux system. Any idea what the problem is?


    Thomas B
     
    Thomas Barth, Jul 18, 2006
    #1
    1. Advertising

  2. Thomas Barth wrote:
    > Hi,
    > I was wondering if someone had any insight to what I am doing wrong. I
    > ve got a class with two methods that call static methods of another
    > class. When compiling my sourcecodes I get the error `expected
    > unqualified-id before "." token` for the two static function calls:
    >
    > ...
    > void V1Drawing::drawLine (double x1, double y1, double x2, double y2)
    > { DPOne.draw_a_line(x1, y1, x2, y2); ###error###


    To call a static member of a class you use '::', not '.' after the class
    name. What book are you reading that doesn't explain that?

    > }
    > [...]


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Jul 18, 2006
    #2
    1. Advertising

  3. Thomas Barth

    Rolf Magnus Guest

    Thomas Barth wrote:

    > Hi,
    > I was wondering if someone had any insight to what I am doing wrong. I
    > ve got a class with two methods that call static methods of another
    > class. When compiling my sourcecodes I get the error `expected
    > unqualified-id before "." token` for the two static function calls:
    >
    > ...
    > void V1Drawing::drawLine (double x1, double y1, double x2, double y2) {
    > DPOne.draw_a_line(x1, y1, x2, y2); ###error###


    DPOne::draw_a_line(x1, y1, x2, y2);

    > }
    >
    > void V1Drawing::drawCircle (double x, double y, double r) {
    > DPOne.draw_a_circle(x, y, r); ###error###


    DPOne::draw_a_circle(x, y, r);

    > }


    You should throw out your C++ book and get a better one instead if it
    doesn't explain this.
     
    Rolf Magnus, Jul 18, 2006
    #3
  4. Thomas Barth

    Thomas Barth Guest

    Victor Bazarov wrote:
    > Thomas Barth wrote:
    >> Hi,
    >> I was wondering if someone had any insight to what I am doing wrong. I
    >> ve got a class with two methods that call static methods of another
    >> class. When compiling my sourcecodes I get the error `expected
    >> unqualified-id before "." token` for the two static function calls:
    >>
    >> ...
    >> void V1Drawing::drawLine (double x1, double y1, double x2, double y2)
    >> { DPOne.draw_a_line(x1, y1, x2, y2); ###error###

    >
    > To call a static member of a class you use '::', not '.' after the class
    > name. What book are you reading that doesn't explain that?
    >


    My book is at home... confused by Java... 32° Celsius...

    Thanks anyway :)

    Thomas B
     
    Thomas Barth, Jul 18, 2006
    #4
    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. Squid Seven
    Replies:
    13
    Views:
    6,652
    Default User
    Jul 15, 2005
  2. Allen
    Replies:
    1
    Views:
    5,406
    Bo Persson
    Dec 25, 2007
  3. tt
    Replies:
    12
    Views:
    2,311
    James Kanze
    Jun 3, 2009
  4. hon123456
    Replies:
    4
    Views:
    3,426
    Francesco S. Carta
    Sep 29, 2009
  5. ahso
    Replies:
    2
    Views:
    8,387
    Richard Herring
    Nov 27, 2009
Loading...

Share This Page