J-XMoses

          J-XMoses

          typedef keyword in C++

          read this article -> http://www.functionx.com/cpp/keywords/typedef.htm
          It 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?
          :)

          posted on 2007-03-22 17:48 Java-XMoses 閱讀(471) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 曲靖市| 东莞市| 临沭县| 上杭县| 富锦市| 南宁市| 新民市| 邵阳市| 静安区| 太湖县| 博爱县| 灵川县| 茌平县| 双峰县| 昭觉县| 新津县| 宝兴县| 驻马店市| 宁津县| 多伦县| 汤原县| 乌拉特后旗| 个旧市| 北海市| 舟山市| 安平县| 怀来县| 广元市| 上思县| 南宫市| 田阳县| 阿巴嘎旗| 博湖县| 东乌珠穆沁旗| 漠河县| 万盛区| 宽城| 永清县| 鹰潭市| 边坝县| 金塔县|