No post-increment operator for type?

I want to test my program but it won't even launch because this error message displays saying, "no post-increment operator for type" on line 37. I have tried to find what this error message means and I didn't really find anything of use. Any help regarding the error message or even improving my code would be appreciated. Thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cmath>
using namespace std;

void inp(int& width, int& space, int& star, double& width2);
void outp(int& width, int& space, int& star, double& width2);

int main()
{
    char cont = 'y';
    int width, space, star;
    double width2;
    
    do//do-while loop allows program to be run multiple times
    {inp(width, space, star, width2);
    outp(width, space, star, width2);
    cin >> cont;}
    while(cont == 'y' || cont == 'Y');
    
    return 0;}
    
void inp(int& width, int& space, int& star, double& width2)//***INPUT***
{
    cout << "Enter the width of a diamond shape and I will output that diamond in asterisks.\n";//prompt
    //Take 'width'
    cin >> width;
    while(width <= 0)//edge case if unitprice is less than 0
    {cout << "The width must be a positive number. Try Again.\n";
    cin >> width;}
    while(width % 2 == 0)
    {cout << "The width must be an even integer. Try Again.\n";
    cin >> width;}
    width2 = width;}

void outp(int& width, int& space, int& star, double& width2)//***OUTPUT***
{    
    for(star = 1; star <= width; count++, space = (width2 / 2) - (star / 2))
    {cout << space << star << space;
    cout << "Do you want to continue? < 'y' or 'n' >: ";}}.

It's supposed to output a "diamond" (really half of a diamond) where width is the largest number of diamonds allowed in a row.
Example:
Input: 7
Output:
*

***

*****

*******

*****

***

*
closed account (Dy7SLyTq)
well you should probably try to look at it yourself because this one is easy to spot. notice on line 37 in the for loop: for(/*some code*/;/*some code*/;count++) i dont see a count variable anywhere else in your program, let alone in your functions scope. i think you meant star
Also, this is an illustration of why using namespace std; is bad practice. I would have expected an error message along the lines of
[Error] 'count' was not declared in this scope

but the compiler must have found something else named count, presumably std::count which exists in the <algorithm> header.
Topic archived. No new replies allowed.