delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/22/08:33:55

From: "Trent and Zacc" <Xzzdengla AT dingo DOT cc DOT uq DOT edu DOT au>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Re: Functions in struct's... possible? How?
Date: Fri, 22 Aug 1997 20:48:50 +1000
Organization: University of Queensland
Lines: 32
Message-ID: <5tjqps$aui$1@nargun.cc.uq.edu.au>
References: <33FCDA5C DOT 2353659F AT execulink DOT com>
NNTP-Posting-Host: zzdengla.slip.cc.uq.edu.au
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

 Look, forget about c++ becuase really, underneath all of the fany object
rubbish are pointers to functions in structs.

Your problem lies with this sentence: "_Pointer_to_function_ in struct", ie.
you have said there is a POINTER to a function in the struct NOT a function.

So, as per an example that was sent as a response shows, you need to make
that pointer point to something before you can call it successfully.

Simple.


Jeff Weeks wrote in article <33FCDA5C DOT 2353659F AT execulink DOT com>...

>I'd like to have a function in a struct that I've created.  I realise I
>can't just stick a functions in there, so I used a pointer to a
>function.  Here's what my struct looks like:
>
>typedef struct {
>  VesaInfo card;           // information about the video card
>  VesaModeInfo mode;       // information about the current mode
>  int bytes_per_line;      // the number of bytes per scanline
>  int size;                // the size in bytes of the whole screen
>  char *address;           // the address of actual video memory
>  void (*blit)(char *);    // a routine to copy a virtual screen to
>memory
>} Driver;
>

<snip>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019