Re: Question on pfVec3. Need explanation.

New Message Reply Date view Thread view Subject view Author view

Veraart (rioj7++at++fel.tno.nl)
Wed, 6 Mar 1996 14:00:31 +0100 (MET)


> I learned that a class should hide its variables allowing access only
> through class methods.

That would be the best.
So you can change the implementation and not the interface.

> Why does pfVec3, being a class, allow access to its 3 components.
Maybe to let people mix C api and C++ api.
>
> And since this happens what is the difference between these two sources:
> a)
> pfVec3 p;
> p.set(1.0f, 2.0f, 3.0f);
> b)
> pfVec3 p;
> p[0]=1.0f;
> p[1]=2.0f;
> p[2]=3.0f;
> Is b) faster than a)?
There is absolutely no difference because the set method is an
inline method.
  
> Not knowing a lot about C++ I find it would be normal for a pfVec3 class
> definition to be present in one of the header files. I didn't find it
> anywhere. Where are the pfVec3 methods defined? I found pfVec3 to be
> defined as
> typedef float pfVec3[3];
> Why is this?

The pfVec3 is not a class but a C++ struct. You can find the definition in
/usr/include/Performer/pr/pfLinMath.h line 202. The difference between a
C++ class and C++ struct is the default inheritance, resp private and public.
The typedef float pfVec3[3]; is from the C-api from
/usr/include/Performer/prmath.h

I hope this explains your questions.

Mario


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:31 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.