Solved

C++ : declaration ? definition ? alias ?

Posted on 2003-10-25
3
633 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countPairs challenge 7 66
C# code editing and collaboration 3 98
c++ reading data from file into two dimensional array 3 96
Advice on Xojo as a development tool over VB. 4 39
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

910 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

17 Experts available now in Live!

Get 1:1 Help Now