small medium large xlarge

Back to: All Forums  Arduino
Generic-user-small
23 Oct 2011, 10:19
chris parkman (1 post)

Hi,

I have a question regarding the code in chapter 4.

[quote] [color=#7E7E7E][b]Telegraph:[/b][/color]:Telegraph(const [color=#CC6600]int[/color] output_pin, const [color=#CC6600]int[/color] dit_length) {   _output_pin = output_pin;   _dit_length = dit_length;   _dah_length = dit_length * 3;   [color=#CC6600]pinMode/color; }

[color=#CC6600]void[/color] Telegraph::output_code(constant [color=#CC6600]char[/color]* code) {   [color=#CC6600]for[/color] ([color=#CC6600]int[/color] i = 0 < strlen(code); i++) {     [color=#CC6600]if[/color] (code[i] == [color=#006699]’.’[/color])     dit();     [color=#CC6600]else[/color]     dah();   } }

[/quote]

the line beginning void Telegraph:: output_code is highlighted when i try to compile the file with the error message

variable or field ‘output_code’ delared void.

I should say that I have 0 code experience, I’ve been working my way through the book and have completely fallen flat on this chapter. I fear I may have bitten off more than I can chew.

Thanks in advance for any help.

Chris

Maik_schmidt_avatar2_pragsmall
23 Oct 2011, 19:25
Maik Schmidt (122 posts)

Hi Chris!

Unfortunately, your code example contains a lot of markup characters, but I’ll give my best.

The function named Telegraph::output_code does not declare a return type in your code sample. It has to be:

void Telegraph::output_code(const char* code)

Please note, that I have also replaced “constant” with “const”.

Did you type the code manually into the IDE? From my experience it’s the safest way for beginners to download the code from the book’s web site (http://pragprog.com/titles/msard/source_code) and play with it. This way you will not run into obscure error messages that result from simple typos.

Cheers, Maik

Generic-user-small
11 Nov 2011, 07:26
Jake Browns (1 post)

Hello

Thanks for the tip. I will try and follow your instructions.

You must be logged in to comment