Solved

C++ : declaration ? definition ? alias ?

Posted on 2003-10-25
3
636 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
ID: 9621432
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
ID: 9621549
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
ID: 9621587
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

785 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