Compiling problen VS2012

Hi guys,
This is a cpp file which used to execute the function in the class' header file.
When I try to compile this code I get this problems:
1)error C2143: syntax error : missing ';' before 'using'
2) error C2059: syntax error : ')'
3)error C2143: syntax error : missing ';' before '{'

There are more errors, but all of them are like those I've mentioned.

Thanks guys, Cheers!

1
2
3
4
5
6
7
8
9
10
11
12
13
#include "stdafx.h"
#include "Person.h"
#include <iostream>
#include <string> 

using namespace std; 

Person() //default C'tor
{
	age=0; 
	_pname="";
	_last_name=""; 
}
This definition is invalid

1
2
3
4
5
6
Person() //default C'tor
{
	age=0; 
	_pname="";
	_last_name=""; 
}


should be

1
2
3
4
5
6
Person::Person() //default C'tor
{
	age=0; 
	_pname="";
	_last_name=""; 
}


However it seems that the reason of errors is in header Person.h
Fixed what you said, all of the errors are gone but the error tells me:
error C2143: syntax error : missing ';' before 'using'

and it's pointing to this line:

 
using namespace std;


Cheers Vlad
@IrarI

Seems to me that the problem lies in your "Person.h", since that is the only place the error could be. (IMO ;) ) Why not post it here, and that can be checked out?
As I said you should look through the header file.
Here's the header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string> 
using namespace std; 

class Person{ 
private: 
	int age; 
	string _pname; 
	string _last_name;
public: 
	Person(); //default C'tor
	Person(string _pname_, string _last_name_, int _age); //non-defualt C'tor 
	Person *next, *back; //pointers to the next and the back object in the list
}
Place a semicolon after the closing brace of the class definition.
Last edited on
@Irari,

I have some input kind of unrelated, but I was researching and learned that starting names with underscores is a dangerous route because those names are typically reserved for implementation and system entities. You may encounter clashes in the future.

Regard,
Incline
Topic archived. No new replies allowed.