[nfbcs] [program-l] Re: Help with Another Assignment

Mike Gorse mike at straddlethebox.org
Fri Nov 3 15:48:35 UTC 2017


I wouldn't say that you're getting a blank line, so much as that your 
program is locking up. Looking at your while loop in averageGrades(), it 
isn't going to terminate in some cases.

On Fri, 3 Nov 2017, Lanie Molinar via nfbcs wrote:

> I fixed it and got it to stop giving me errors, but I’m now having another issue. For the condition that’s supposed to cout dashes, I get only a blank line after I enter -1 for all 10 grades.
>
> Sent from Mail for Windows 10
>
> From: Dzhovani Chemishanov
> Sent: Friday, November 3, 2017 9:22 AM
> To: Lanie Molinar
> Cc: program-l at freelists.org; Lanie Molinar via nfbcs
> Subject: Re: [program-l] Re: [nfbcs] Help with Another Assignment
>
> Hi,
>  As I said, my c++ is rusty but still I'd be quite surprised to find
> working code of the type:
> cout << some_text << a_void_function();
> It is okay to have a cout statement in a void function, but it is not
> okay to have a void function in a cout statement.
> Any other type of function that returns printable result could be
> called from a cout, but the fundamental property of void functions is
> that they do not return value to be sent to the c out stream.
>  Can you check your previous project and compare the approach there
> with the current one?
>
> On 11/3/17, Lanie Molinar <laniemolinar91 at gmail.com> wrote:
>> Hi. I’ve used cout statements this way in a void function before, though, so
>> I don’t understand why it doesn’t work. In a project I did just a couple
>> weeks ago, I created a display function that was void but had multiple cout
>> statements in it. This seems like the same kind of thing.
>>
>> Sent from Mail for Windows 10
>>
>> From: Dzhovani Chemishanov
>> Sent: Friday, November 3, 2017 8:26 AM
>> To: program-l at freelists.org
>> Cc: Lanie Molinar via nfbcs; laniemolinar91 at gmail.com
>> Subject: Re: [program-l] Re: [nfbcs] Help with Another Assignment
>>
>> this line
>> cout << "Average Grade: " << averageGrades(grades, NUMGRADES) << "%\n";
>> the function that you are calling is void and you can't print result
>> from it because it doesn't return anything.
>> move all cout statements in it and avoid all the mess.
>> Also, my cpp is rusty, so I hope that the way you are trying to fill
>> in the array is valid.
>> HTH,
>> Dzhovani
>>
>> On 11/3/17, Mike Gorse <mike at straddlethebox.org> wrote:
>>> Hi Lanie,
>>>
>>> If I try to compile your code, then I get this error:
>>>
>>> a31.cpp:71:30: error: no match for ‘operator<<’ (operand types are
>>> ‘std::basic_ostream<char>’ and ‘void’)
>>>      cout << "Average Grade: " << averageGrades(grades, NUMGRADES) <<
>>> "%\n";
>>>
>>> The "void" is the key here--the compiler thinks that you are trying to
>>> pass something with a void type to the stream. From that, I'd guess that
>>> averageGrades() isn't returning a value. When I look at the function
>>> prototype, it is, in fact, returning void, rather than returning a value
>>> that can be printed by the caller.
>>>
>>> Hth,
>>> -Mike
>>> ---311908982-671148510-1509712654=:14384--
>>> ** To leave the list, click on the immediately-following link:-
>>> ** [mailto:program-l-request at freelists.org?subject=unsubscribe]
>>> ** If this link doesn't work then send a message to:
>>> ** program-l-request at freelists.org
>>> ** and in the Subject line type
>>> ** unsubscribe
>>> ** For other list commands such as vacation mode, click on the
>>> ** immediately-following link:-
>>> ** [mailto:program-l-request at freelists.org?subject=faq]
>>> ** or send a message, to
>>> ** program-l-request at freelists.org with the Subject:- faq
>>>
>>
>>
>
>


More information about the NFBCS mailing list