[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: [PROGRAMMERING] array af funktioner, initialisering og kald af dem.



torsdag 22 februar 2007 15:20 skrev Peter Maersk-Moller:
> Hej
> 
> Tak for de i grund og bund to forskellige tilgangsvinkler.
> Begge er interessanted. Jeg er lidt i tvivl om Roberts brug af maps 
> eller std::maps. Jeg er nok ikke dygtigt nok, endnu. Hvor kan man læse 
> lidt om det, da det åbenbart ikke er med i min basale viden om C++ ?
> 

Den her er god: 
http://www.amazon.com/Accelerated-C++-Practical-Programming-Example/dp/020170353X

Hold dig fra Bjarne, så længe du kan (ja, der vil sikkert være nogen der 
sværger til ham, men det er folk der allerede kan C++).

Mads

> Peter
> 
> Michael Rasmussen wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > On Wed, 21 Feb 2007 19:31:16 +0100
> > Hans-Christian Stadler <sslug@sslug> wrote:
> > 
> >> Hvis det nu skal være C++ (--) = C
> >>
> > Nu er det ikke for at være krakiler, men hvis intentionen er, at det
> > skal være C, skal dit eksempel tilrettes til følgende:
> > 
> > #include <stdio.h>
> > 
> > int adecode(char *p, char *t);
> > int vdecode(char *p, char *t);
> > int tdecode(char *p, char *t);
> > 
> > int (*f[3])(char *p, char *t);
> > 
> > void setup(int index, int (*decode)(char *p, char *t)) {
> > 	f[index] = decode;
> > }
> > 
> > int call_f(int index, char *p, char *t) {
> > 	return f[index](p, t);
> > }
> > 
> > int main (int argc, char *argv[])
> > {
> > 	int i;
> > 
> > 	setup(0, adecode);
> > 	setup(1, vdecode);
> > 	setup(2, tdecode);
> > 	for (i=2; i>=0; --i)
> > 		call_f(i, "hej", " der");
> > 	return 0;
> > }
> > 
> > int adecode(char *p, char *t) {
> > 	printf("adecode: %s%s\n", p, t);
> > 	return 0;
> > }
> > 
> > int vdecode(char *p, char *t) {
> > 	printf("vdecode: %s%s\n", p, t);
> > 	return 0;
> > }
> > 
> > int tdecode(char *p, char *t) {
> > 	printf("tdecode: %s%s\n", p, t);
> > 	return 0;
> > }
> > 
> > Den resulterende binære fil fylder også 25% mindre.
> > - -rwxr-xr-x 1 mir  mir    7469 2007-02-21 19:44 test_c
> > - -rwxr-xr-x 1 mir  mir    9503 2007-02-21 19:40 test_cc
> > 
> > $ dpkg -s gcc
> > Package: gcc
> > Status: install ok installed
> > Priority: standard
> > Section: devel
> > Installed-Size: 64
> > Maintainer: Debian GCC Maintainers <sslug@sslug>
> > Architecture: i386
> > Source: gcc-defaults (1.50)
> > Version: 4:4.1.1-15
> > 
> > $ dpkg -s g++
> > Package: g++
> > Status: install ok installed
> > Priority: standard
> > Section: devel
> > Installed-Size: 40
> > Maintainer: Debian GCC Maintainers <sslug@sslug>
> > Architecture: i386
> > Source: gcc-defaults (1.50)
> > Version: 4:4.1.1-15
> > 
> > - -- 
> > Hilsen/Regards
> > Michael Rasmussen
> > http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917
> > A computer is like air conditioning: it becomes useless when you open
> > windows.
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.6 (GNU/Linux)
> > 
> > iD8DBQFF3JQEVErYVePoCRcRAnccAJoC1jQjBmjk7AvoOuR7A3eifp8ZYwCaA0AI
> > BqNCgZNNqtaWZNFlu67Zh7M=
> > =EzNK
> > -----END PGP SIGNATURE-----
> 
> 
> 

-- 
Mads Bondo Dydensborg.                               sslug@sslug
Maybe you don't care about Microsoft's victims. When Microsoft starts
charging you for every time you turn your computer on, will you care then?
                                        - Melantha Bacchae on /.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-03-01, 02:01 CET [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] *