Solved

C++ : declaration ? definition ? alias ?

Posted on 2003-10-25
3
650 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
Six Sigma Control Plans

630 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