So I this is a sample code. I just started using Visual C++ 2010 Express Edition, and I keep getting this error along with others but this bothers me a lot.
Program 9.cpp(15): error C2146: syntax error : missing ‘)’ before identifier ‘s’
Here’s my code:
#include <iostream>
#include <conio.h>
#include <string>
#include <string.h>
using namespace std;
class Salesman
{
char name[26];
float total_sales;
public:
Salesman (char *s, float f)
{
strcpy(name s); //Error occurs here. :(
total_sales=f;
}
void prnobject (void)
{
cout<<this->name;
cout<<"\tHas invoked probject: \n";
}
};
void main()
{
clrscr();
salesman Raman ("Raman", 21450), Sita ("Sita", 23190), Vedant ("Vedant", 19142);
Raman.prnobject();
Sita.prnobject();
Vedant.prnobject();
getch();
}
You need a comma:
C++ requires that you separate your arguments with a comma – you can’t just list the names with spaces separating the arguments.