typedef keyword in C++

typedef keyword in C++
read this article -> http://www.functionx.com/cpp/keywords/typedef.htmIt said that "The typedef keyword can be followed by an attribute before the data type. In its simplest form, the attribute can be that of an access level such as public, private, or protected." and provide a examples:
#include <iostream>
#include <string>
using namespace std;

typedef struct Student;
typedef class Country;

typedef public short SmallNumber;
typedef private unsigned int Positive;
typedef protected double* PDouble;
typedef public string FiveStrings[5];
typedef private double (*Addition)(double value1, double value2);

struct Student
{
	string FirstName;
	string LastName;
};

typedef struct _Empl
{
	string FullName;
	double HourlySalary;
}Employee;

class Country
{
	string Name;
	string Capital;
	string Code;
};

double Add(double x, double y)
{
	double result = x + y;
	return result;
}

typedef enum EmplStatus { esFullTime, esPartTime, esContractor };
typedef Student *PStudent;
typedef Country *PCountry;

int main()
{
	Student pupil;
	Country pais;
	EmplStatus emplst;
	PStudent ptrStd = new Student;
	PCountry pPais = new Country;

	return 0;
}

I found that I can't compile it on my Linux using g++.
[root@sd1 xxx]# g++ typedef.cpp -o typedef
typedef.cpp:8: error: expected unqualified-id before 'public'
typedef.cpp:9: error: expected unqualified-id before 'private'
typedef.cpp:10: error: expected unqualified-id before 'protected'
typedef.cpp:11: error: expected unqualified-id before 'public'
typedef.cpp:12: error: expected unqualified-id before 'private'
Why, can anybody tell me?
:)

좋은 웹페이지 즐겨찾기