Pages: [1]   Go Down
Author Topic: non-class type error  (Read 425 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(unfinished) sketch:
Quote
#include <seg.h>

Seg seg();

void setup()
{
}

void loop()
{
  digitalWrite(2, HIGH);
  seg.one();
  digitalWrite(2, LOW);
  delay(2);
  digitalWrite(3, HIGH);
  seg.two();
  digitalWrite(3, LOW);
  delay(2);
  digitalWrite(4, HIGH);
  seg.three();
  digitalWrite


Header File:

Quote
#ifndef Seg_h
#define Seg_h

#include "WProgram.h"

class Seg
{
  public:
  Seg();
  void one();
  void two();
  void three();
  void four();
  void five();
  void six();
  void seven();
  void eight();
  void nine();
  void zero();
  private:
};

#endif



Source File:
Quote
#include "WProgram.h"
#include "Seg.h"

 Seg::Seg()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}
void Seg::one()
{
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
}
void Seg::two()
{
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);
}
So on and so forth to 9.

This is a library to control a 4 digit, 7segment led display.

When I try to compile what i have so far it highlights "  seg.one();" and says "seg_seg:11: error: request for member 'one' in 'seg', which is of non-class type 'Seg () ()'"


Any ways to fix this?

Thanks
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 203
Posts: 8722
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This declares a function which RETURNS a Seg:
Code:
Seg seg();

I think what you intended to do was declare "seg" as an instance of Seg:
Code:
Seg seg;
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post you r code so we can see all of it.

And please use the # button for posting code to get it proper tagged with [ code] tags, looks so much better.

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Full Member
***
Karma: 0
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It was too long so i couldnt post it, i only cout out the repetitive stuff.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did "Seg seg;" instead of "Seg seg();" and it worked. Thanks
Logged

Pages: [1]   Go Up
Jump to: