[Error] expected primary-expression before ']'

Hi there; I'm working on this code for school and I got pretty far but now I'm 100% stumped. I keep getting the error: [Error] expected primary-expression before ']' about lines 72-74. Can anyone help?
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
 #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
class Seller
{
public:
  Seller();
  Seller( const char [], const char[], const char [], double );
    
  void print();

  void setFirstName( const char [] );
  void setLastName( const char [] );
  void setID( const char [] );
  void setSalesTotal( double );

  double getSalesTotal();

private:
  char firstName[20];
  char lastName[30];
  char ID[7];
  double SalesTotal;
};
int main()
{
	Seller first  = Seller("Luke","Schwaller","CSCI240",1234.56);
	Seller second = Seller();
	Seller third  = Seller("","Johnson","TOOBIG999",876.34);
	Seller fourth = Seller("James","Hellwig","ULTWAR",13579.11);
	Seller fifth  = Seller("Roderick","Toombs","PIPER4",24680.24);
	
	
		
	cout<<" **** The first Seller object ****"<<endl<<endl;
	first.print();
	cout<<"\n\n**** The second Seller object ****"<<endl<<endl;
	second.print();
	second.setFirstName("Terry") ;
	second.setLastName("Bollea");
	second.setID("HULK96");
	second.setSalesTotal(246.80);
	second.print();
	cout<<"\n\n*** The third Seller object ***"<<endl<<endl;
	third.print();
	third.setFirstName("Dwayne");
	third.setID("ROCK89");
	third.print();
	cout<<"\n\n*** The fourth Seller object ***"<<endl<<endl;
	fourth.print();
	cout<<"\n\n*** The fifth Seller object ***"<<endl<<endl;
	fifth.print();
	fifth.setFirstName("");
	fifth.setLastName("");
	fifth.setID("");
	fifth.setSalesTotal(-19.88);

}
Seller::Seller()
{
	setFirstName("None");
	setLastName("None");
	setID("ZZZ000");
	setSalesTotal(0);
}
Seller::Seller( const char newFirstName[], const char newLastName[], const char newID[], double newSalesTotal ){


	firstName = newFirstName[];
	lastName =  newLastName[];
	ID =  newID[];
	SalesTotal = newSalesTotal;
	
	

}
void Seller::print()
{
     cout << fixed << setprecision(2);
   
     cout << lastName << ", " << firstName 
        << " " << ID << " "<< SalesTotal ;
   }

void Seller::setFirstName(const char newFirstName[])
{
	if( strlen(newFirstName) > 0 )
	{
		strcpy(firstName, newFirstName);
	}
	else
	{
		strcpy( firstName, "None");
	}
}
void Seller::setLastName(const char newLastName[])
{
	
	if( strlen(newLastName) > 0 )
	{
		strcpy(lastName, newLastName);
	}
	else
	{
		strcpy( lastName, "None");
	}
}
void Seller::setID(const char newID[])
{
	
	if( strlen(newID) > 0 ) 
	{
		if (strlen(newID)< 7)
		{
		
			strcpy(ID, newID);
		}
	}
	else
	{
		strcpy( ID, "None");
	}
}
void Seller::setSalesTotal(double newSalesTotal)
{
	 if(newSalesTotal < 0)
	{
		SalesTotal = newSalesTotal;
	}
	else
	{
		SalesTotal = 0;
	}
}
double Seller::getSalesTotal()
{
	return SalesTotal;
}

https://imgur.com/a/Ndzkf
Last edited on
Lines 72-74: You can't assign arrays like that. Call your setters.
Topic archived. No new replies allowed.