# A bloody beginner's question " expected constructor, destructor, or..."

Hello everybody!

I’m an absolutely new to the whole topic of programming. I already did a few very simple sketches without using my own functions and some projects from Boxal’s Book. Now, I trying to do my own function, but it just doesn’t work. >:(
I’m “simply” trying to build a function that will print the result of the equation z=y+x with z=n+1 onto the serial monitor, i.e. a simple count-up 1, 2, 3, […] .

I alway get this f***ing error message: “expected constructor, destructor, or type conversion before ‘int’”

``````void setup()
{
Serial.begin(9600);
}

Zahlen()
{
int x;
int y;
int z;
for(int a=0; a<=0; a++) // Hier müssen ; statt , hin !!!
{
x=0;
y=1;
z=x+y;
}
}

void loop()
{
Serial.print(Zahlen);
}
``````

You forgot to give your function a type. Since it doesn't return anything it should be void:

``````void Zahlen()
``````

When you get past that problem, look at this:

``````  for(int a=0; a<=0; a++) // Hier müssen ; statt , hin !!!
``````

How can “a” become less than zero? It starts at 0 and counts up.
Is 0<=0 true? Yes. What about 1<=0?

This for loop runs exactly once. Maybe you don’t need it.

You should go to google and search “C++ tutorial” and spend a few hours working through one of the basic lessons on C++. You’ve got the right idea, you just need to pay attention to syntax.

To create a function you must declare its return type even if that type is void. Look at setup and loop functions for examples. When you call a function, you need the parenthesis after it. Just writing the name of the function alone is not calling it.

``````Serial.print(Zahlen());
``````

If you are going to try to print a return value from your function like the line in loop implies, then your function should actually include a return statement somewhere.

``````for(int a=0; a<=0; a++)
``````

You should probably read up on how for loops work before you go any further. It isn’t very clear why you think you need one at all, but that one is most definitely wrong. It would only iterate once, and a for loop hat only iterates once is as useless as a screen door on a submarine.

Really, a few hours with a basic C++ tutorial would get you on track.

pert:
You forgot to give your function a type. Since it doesn't return anything it should be void:

``````void Zahlen()
``````

Yes, however I think you are trying to return an int so you can print it. But you are plagued with other multiple problems. You have tried to do too much at once. Build up to it gradually.

"I already did a few very simple sketches without using my own functions and some projects from Boxal's Book"

Did you go through the examples that came with the IDE.

Do you fully understand the code in each of these examples.

If you have problems understanding what is going on in these examples, ask for help in understanding these examples.

.

That was fast! Thanks!

Hottepunz:
I alway get this f***ing error message: "expected constructor, destructor, or type conversion before 'int'"

Also note that the compliler error message is actually telling you there is a problem with the line;

Zahlen()

So a question to ask yourself is, what is different about the Zahlen() to other simlar lines in the program.