By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 2,698 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

expected unqualified-id before "." token?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.