Author Topic: Can't create a function which returns void. Please help  (Read 2906 times)

Offline HealingAura

  • Single posting newcomer
  • *
  • Posts: 6
Can't create a function which returns void. Please help
« on: June 29, 2006, 10:58:38 am »
Can someone please help me?
I have an error with this code:

Code: [Select]
class Symbols
{
private:
char code[27]; // The encoding of each letter
Letter **c; // The Letters from a-z
Key2Letter **key; // The keys for the letters
char stop; // When to stop reading from input
int number;
public:
Symbols();
void Remove(int num);
void Switch(int num1,int num2);
void SortNewList();
friend istream &operator>>(istream &in,Symbols &s);
friend ostream &operator<<(ostream &out,Symbols &s);
void InsertList (Key2List* k);
};

The error is:

Code: [Select]
main.cpp:164: error: variable or field `InsertList' declared void // In the line of InsertList
  main.cpp:164: error: expected `;' before '(' token // In the line of InsertList
main.cpp:180: error: expected `;' before "void // In the line of the end of the class"


I searched but there was no mistake. I searched this on the web but couldn't find an answer.
Someone can help me please and tell me what's wrong?

Offline BigAngryDog

  • Multiple posting newcomer
  • *
  • Posts: 75
    • BigAngryDog.com
Re: Can't create a function which returns void. Please help
« Reply #1 on: June 29, 2006, 01:07:28 pm »
Your line:

void InsertList (Key2List* k);

has an erroneous space between "InsertList" and "(...".

:)
BigAngryDog.com

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Can't create a function which returns void. Please help
« Reply #2 on: June 29, 2006, 01:17:31 pm »
void InsertList (Key2List* k);
has an erroneous space between "InsertList" and "(...".
No, that doesn't matter. It is not pretty, but it is not wrong either.


The error is not in the piece of code you posted, it compiles fine (with include and forward decl added):
Code: [Select]
#include <ios>
using namespace std;

class Letter;
class Key2Letter;
class Key2List;

class Symbols
{
private:
char code[27]; // The encoding of each letter
Letter **c; // The Letters from a-z
Key2Letter **key; // The keys for the letters
char stop; // When to stop reading from input
int number;
public:
Symbols();
void Remove(int num);
void Switch(int num1,int num2);
void SortNewList();
friend istream &operator>>(istream &in,Symbols &s);
friend ostream &operator<<(ostream &out,Symbols &s);
void InsertList (Key2List* k);
};

int main()
{
    return 0;
}

Code: [Select]
-------------- Build: default in console ---------------
mingw32-g++.exe  -IC:\mingw\include  -c main.cpp -o .objs\main.o
mingw32-g++.exe -LC:\mingw\lib  -o console.exe .objs\main.o   
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
It must be somewhere else. Forgotten ";" in some earlier place maybe?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline HeroreV

  • Single posting newcomer
  • *
  • Posts: 6
Re: Can't create a function which returns void. Please help
« Reply #3 on: July 07, 2006, 05:21:17 am »
The compiler is not recognizing a type named "Key2List". Probably you forgot to include the header defining the Key2List type or it's actually named something else.