468,512 Members | 1,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

expected unqualified-id before "." token?

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
Jul 18 '06 #1
3 39588
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
Jul 18 '06 #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###
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.

Jul 18 '06 #3
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
Jul 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Erik Moore | last post: by
1 post views Thread by junky_fellow | last post: by
1 post views Thread by Simon | last post: by
3 posts views Thread by mavis | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.