Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > expected unqualified-id before "." token?

Reply
Thread Tools

expected unqualified-id before "." token?

 
 
Thomas Barth
Guest
Posts: n/a
 
      07-18-2006
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:POne() {
}

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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-18-2006
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


 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      07-18-2006
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.

 
Reply With Quote
 
Thomas Barth
Guest
Posts: n/a
 
      07-18-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
expected class-name before '{' bubzilla C++ 19 09-29-2006 01:33 PM
Header include problems error: expected class-name before '{' token bubzilla C Programming 2 09-25-2006 10:52 AM
expected constructor, destructor, or type conversion before '*' Preben C++ 6 09-20-2006 07:15 PM
error: expected initializer before '&' token andrew browning C++ 16 03-13-2006 07:55 AM
"expected unqualified-id before 'using'" Squid Seven C++ 13 07-15-2005 05:54 PM



Advertisments