Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Mar 27, 2000

The Linkage Type of Typedef Names

By default, a typedef name declared in the global scope has internal linkage. This means that separately compiled source files can't refer to a typedef declared in another source file, unless that typedef is explicitly declared "extern." In this respect, C++ is different from C, which make typedef names global by default. Thus, in C++ you are allowed to define the same typedef name in every separately compiled source file as long as the definitions are identical:

 
// file first.cpp
  typedef int I; // visible only in the scope of this file
  void func(I);

// file second.cpp
  typedef int I; // visible only in the scope of this file
  float func2(I);
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date