virtual class members 
Author Message
 virtual class members

class axon
{
     public:
         double impsum;
         double threshold;
          int flag;
          virtual void check_spasm();
          virtual void init_ax();

     private:

Quote:
};

I have an object that is:

axon ax[10][10][10];

And my question is:  How do I make it so impsum is a different
variable for each of ax[i][j][k] ?

I know some C++ but am having this issue:  all of the impsum are taken
from a global impsum and not an individualized impsum. How do I get
one for each axon?

And what does type "virtual" do for class functions and why can't I
use it with variables?

TIA,

Bryce



Sun, 27 Mar 2005 09:20:01 GMT  
 virtual class members

Quote:

> class axon
> {
>      public:
>          double impsum;
>          double threshold;
>           int flag;
>           virtual void check_spasm();
>           virtual void init_ax();

>      private:
> };

> I have an object that is:

> axon ax[10][10][10];

> And my question is:  How do I make it so impsum is a different
> variable for each of ax[i][j][k] ?

> I know some C++ but am having this issue:  all of the impsum are taken
> from a global impsum and not an individualized impsum. How do I get
> one for each axon?

> And what does type "virtual" do for class functions and why can't I
> use it with variables?

> TIA,

> Bryce

But there is a different impsum variable for each instance!  To help see
that, try using the de{*filter*} or printf to view the address of several of
the impsum's.  You are probably misinterpreting things somehow.  

"virtual" makes the function overridable by derived classes.  If you do
such an override then when the base class calls check_spasm() the call
is transferred to the derived class version.  It is a way for you to
change the behavior or the original (base) function.  You can't change
the behavior of doubles and ints, so the concept does not apply to
variables.

--
Scott McPhillips [VC++ MVP]



Sun, 27 Mar 2005 10:26:38 GMT  
 virtual class members
OK, I think I know what is going on.

They all have the same value for the impsums, which makes sense
because they are going through all the same steps.  I didn't think of
that before.  But at least two should be different and I have a lot of
debugging to do.

Thanks for your help!


Quote:

> > class axon
> > {
> >      public:
> >          double impsum;
> >          double threshold;
> >           int flag;
> >           virtual void check_spasm();
> >           virtual void init_ax();

> >      private:
> > };

> > I have an object that is:

> > axon ax[10][10][10];

> > And my question is:  How do I make it so impsum is a different
> > variable for each of ax[i][j][k] ?

> > I know some C++ but am having this issue:  all of the impsum are
taken
> > from a global impsum and not an individualized impsum. How do I
get
> > one for each axon?

> > And what does type "virtual" do for class functions and why can't
I
> > use it with variables?

> > TIA,

> > Bryce

> But there is a different impsum variable for each instance!  To help
see
> that, try using the de{*filter*} or printf to view the address of
several of
> the impsum's.  You are probably misinterpreting things somehow.

> "virtual" makes the function overridable by derived classes.  If you
do
> such an override then when the base class calls check_spasm() the
call
> is transferred to the derived class version.  It is a way for you to
> change the behavior or the original (base) function.  You can't
change
> the behavior of doubles and ints, so the concept does not apply to
> variables.

> --
> Scott McPhillips [VC++ MVP]



Sun, 27 Mar 2005 10:48:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. nested class virtual members

2. VC++ error: Derived class Virtual member functions.

3. Virtual Classes and Member functions

4. Copy a class with virtual member function

5. List Members show old (deleted) class members

6. Serialize class derived from virtual base class

7. compiler warning of internal virtual member

8. forced to use virtual members

9. virtual static member variable

10. Virtual Member Functions

11. virtual used for static member function

12. abstract and virtual members

 

 
Powered by phpBB® Forum Software