Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Stroustrup Chapter 4, Exercise 2

Reply
Thread Tools

Stroustrup Chapter 4, Exercise 2

 
 
arnuld
Guest
Posts: n/a
 
      03-05-2007
Stroustrup has a table in section 4.9 of declarations and
definitions. he asks to write a similar table but in opposite sense:

char ch; // declaration with definition

he asks to do the opposite as an exercise which is writing it as a
"declaration without definition". please check whether i am right or
wrong:



1. char ch; - extern char ch;

2. string s; - extern string s;

3. int count = 1; - extern int count;

4. const double pi = 3.14159...... - extern const double pi;

5. extern int error_number; - int error_number; or
int error_number = 1;

6. const char* name = "Nijal" - extern const char* name;

7. const char* season[] = { "spring", "summer", "fall", "winter" };

- extern const char* season[];

8. struct Date { int d, m, y; }; - struct Date;

9. int day(date* p) { return p->d };

- int day(Date*);

10. double sqrt(double); - double sqrt(double) { }

11. template<class T>T abs(T a) { return a < 0? -a : a; }

- template<class T>T abs(T a);

// just guessed for it, as i know nothing about templates


12. typedef complex<short> Point;

// i have NO idea about what is this.

13. struct User; - struct User {}

14. enum Beer { carlsberg, Tuborg, Thor };

- enum Beer;

15. namespace NS { int a; }

- namespace NS;

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stroustrup Chapter 4, Exercise 5 arnuld C++ 4 03-05-2007 04:05 PM
Stroustrup Chapter 4, Exercise 3 - displaying the sizes of char, int etc. arnuld C++ 0 03-05-2007 03:18 PM
Stroustrup: chapter 4 arnuld C++ 13 03-05-2007 07:41 AM
Stroustrup "desk calculator" chapter 6 arnuld C++ 14 11-11-2006 04:14 AM
Stroustrup chapter 3 - 3.6 arnuld C++ 4 11-05-2006 11:25 AM



Advertisments