Solved

C++ : declaration ? definition ? alias ?

Posted on 2003-10-25
3
631 Views
Last Modified: 2012-05-04
To C++ expert ?

   Is "extern float a" a declaration ?
   Is the "namespace mystd = std" a declaration ? definition ? or alias ?

   Also, is the "tydef unsigned char byte" a declaration ? definition ? or alias ?

   Thanks a lot !

meow .....
0
Comment
Question by:meow00
3 Comments
 
LVL 1

Expert Comment

by:marcin1
Comment Utility
I'm not an expert, but let's try

---------------------------------
extern float a;
This is a declaration, because you don't initialize the value of a.

---------------------------------
namespace mystd = std;

This way you make an alias of the namepace. Compare it to this:

namespace mynamespace
{
       ...
}

Here the namespace is both declared and defined.

---------------------------------
typedef unsigned char byte;
It is a type definition and has nothing to do with variable, function etc. declarations/definitions or namespace aliases.
0
 
LVL 1

Author Comment

by:meow00
Comment Utility
I am sort of confused here .... because based on
"C++ in a nutshell" p24 and p28 .... typedef is only a declaration ?? I don't know if I miss understand it here.....
since this original question ask which of the three is a definition.... then I don't  know if "namespace = std"  a definition
or not ... ?
thanks.
0
 
LVL 9

Accepted Solution

by:
tinchos earned 70 total points
Comment Utility
Is "extern float a" a declaration ?

Yes, it is a declaration.

"The keyword extern provides a method for declaring an object without defining it. Similar in effect to a function declaration, it
promises that the object is defined elsewhere, either somewhere else in this text file or in another text file of the program."*

Is the "namespace mystd = std" a declaration ? definition ? or alias ?

It's an alias. From that moment on it will be the same for you to talk about namespace mystd or namespace std.

Also, is the "tydef unsigned char byte" a declaration ? definition ? or alias ?

Is a definition, because in it you define what the byte type is going to represent.

* From C++ Primer 3rd Edition (Lipman)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now