A
arnuld
i did what i could do at Best to solve this exercise and this i what i
have come up with:
----------- PROGRAMME --------------
/* Stroustrup 5.9, exercise 3
STATEMENT:
Use typedef to define the types:
unsigned char
const unsigned char
pointer to integer
pointer to pointer to char
pointer to array of char
array of 7 pointers to int
pointer to an array of 7 pointers to iint
array of 8 arrays of 7 pointers to int
*/
#include<iostream>
int main()
{
typedef unsigned char Uchar;
typedef const unsigned char CUchar;
typedef int* Pi;
typedef char** PPi;
// to define a type for "pointer to an array of char"
// using typedef
const int arr_size = 10;
char arr[arr_size];
char* pac = &arr;
typedef pac PAchar;
// to define a type for "array of 7 pointers to int"
// using typedef
const int arr_size2 = 7;
typedef int* arr2[arr_size2] Arr7Pint;
// to define a type for
// "a pointer to an array of 7 pointers to int"
// using typedef
int** ppi = arr2;
typedef ppi PPint;
// to define a type for
// "array of 8 arrays of 7 pointers to init"
// using typedef
const int arr_size3= 8;
PPint arr3[arr_size3];
return 0;
}
------------ OUTPUT ----------------
[arch@voodo tc++pl]$ g++ 5.9_ex-03.cpp
5.9_ex-03.cpp: In function 'int main()':
5.9_ex-03.cpp:31: error: cannot convert 'char (*)[10]' to 'char*' in
initialization
5.9_ex-03.cpp:32: error: 'pac' does not name a type
5.9_ex-03.cpp:37: error: expected initializer before 'Arr7Pint'
5.9_ex-03.cpp:42: error: 'arr2' was not declared in this scope
5.9_ex-03.cpp:43: error: 'ppi' does not name a type
5.9_ex-03.cpp:49: error: 'PPint' was not declared in this scope
5.9_ex-03.cpp:49: error: expected `;' before 'arr3'
[arch@voodo tc++pl]$
have come up with:
----------- PROGRAMME --------------
/* Stroustrup 5.9, exercise 3
STATEMENT:
Use typedef to define the types:
unsigned char
const unsigned char
pointer to integer
pointer to pointer to char
pointer to array of char
array of 7 pointers to int
pointer to an array of 7 pointers to iint
array of 8 arrays of 7 pointers to int
*/
#include<iostream>
int main()
{
typedef unsigned char Uchar;
typedef const unsigned char CUchar;
typedef int* Pi;
typedef char** PPi;
// to define a type for "pointer to an array of char"
// using typedef
const int arr_size = 10;
char arr[arr_size];
char* pac = &arr;
typedef pac PAchar;
// to define a type for "array of 7 pointers to int"
// using typedef
const int arr_size2 = 7;
typedef int* arr2[arr_size2] Arr7Pint;
// to define a type for
// "a pointer to an array of 7 pointers to int"
// using typedef
int** ppi = arr2;
typedef ppi PPint;
// to define a type for
// "array of 8 arrays of 7 pointers to init"
// using typedef
const int arr_size3= 8;
PPint arr3[arr_size3];
return 0;
}
------------ OUTPUT ----------------
[arch@voodo tc++pl]$ g++ 5.9_ex-03.cpp
5.9_ex-03.cpp: In function 'int main()':
5.9_ex-03.cpp:31: error: cannot convert 'char (*)[10]' to 'char*' in
initialization
5.9_ex-03.cpp:32: error: 'pac' does not name a type
5.9_ex-03.cpp:37: error: expected initializer before 'Arr7Pint'
5.9_ex-03.cpp:42: error: 'arr2' was not declared in this scope
5.9_ex-03.cpp:43: error: 'ppi' does not name a type
5.9_ex-03.cpp:49: error: 'PPint' was not declared in this scope
5.9_ex-03.cpp:49: error: expected `;' before 'arr3'
[arch@voodo tc++pl]$