expected unqualified-id before "." token?

T

Thomas Barth

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
 
V

Victor Bazarov

Thomas said:
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
 
R

Rolf Magnus

Thomas said:
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.
 
T

Thomas Barth

Victor said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top