[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Re: [NOVICE] C++



> > > Nu vi er ved det, er det heller ikke særlig god prgrammeringsskik
> > > (eller i overensstemmelse ISO'en) at dumpe iostream-klasen i globalt
> > > navnerum med <iostream.h>. :)

Programmering er det muliges kunst - med de oversættere jeg nævnte (djgpp 
er strengt taget ikke en oversætter (men gcc under djgpp er)) er ikke 
laveste - men højst mulige fællesnævner <iostream.h> ikke <iostream>;-)

Generelt burde gælde at
        <iostream.h> er "depreciated" - men der undervises stadig i den 
hvilket er ganske fornuftigt da den i modsætning til <iostream> indtil 
videre understøttes af alle af mig kendte oversættere.
        Alle klasser i <iostream.h> er erklæret i global namespace.
        Den "vigtigste" klasse defineret i <iostream.h> er ::iostream.

        <iostream> definerer kun een klasse: basic_iostream<typename 
charT, typename traits> ganske korrekt i std namespace.

Sålænge man bruger og referer til <iostream.h> er det derfor *god 
programeringsskik* (det er faktiskt den eneste mulighed) "at dumpe 
iostream-klassen i" global namespace.


> For at tilgå std må man ifølge standarden enten:
>
> 1) deklarere hele std i det globale navnerum:
> 2) bruge scope-operatoren til at tilgå std
> 3) deklarere specifikke objekter fra std i det globale

eller
4) bruge en læselig version "that does not contaminate your bodily 
fluids"!(global namespace)(undskyld! men jeg kunne altså ikke lade 
være;;-):

// *My* Favorite STL syntax:
#include <ostream>
extern "C++" {
        int main() {
                using namespace std;
                cout << "This is my favorite STL-syntax" << endl; // Tak 
til Frank Damgaard
                return int();
        }
}

Jeg har endnu ikke mødt den implementation der både kan oversætte og linke 
ovenstående.
Jeg glæder mig til at afprøve gcc3.0!

Hej fra Nils!


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *