[Stk] newbie question

Perry R Cook prc@CS.Princeton.EDU
Sat, 24 Mar 2007 12:44:49 -0400 (EDT)


Josep,

Michael is right on.

You need to use the pointer form if you want to
call a constructor that takes arguments.  A class
may have more than one constructor, a default without
arguments, which is automagically called when you
declare an instance of it, and others which might
take arguments.

PRC


On Sun, 25 Mar 2007, Michael Chinen wrote:

> Hi Josep,
>
> STK is written for C++, so objects will be allocated when their
> variables are declared.
>
> SineWave sine;
>
> will allocate and call the SineWave() constructor for the sine
> variable behind the scenes.
>
> You are of thinking of Java or C#, perhaps, where objects are all pointers.
> If you want to do newing, you will need to explicitly declare the
> variable a pointer, such as
>
> SineWave* sine = new SineWave();
> sine->setFrequency(..);
>
> HTH
>
> Michael
>
>
>
> On 3/24/07, Josep M Comajuncosas <josep.comajuncosas@wanadoo.es> wrote:
>> 
>> 
>> Hi,
>> just an , I guess, idiomatic question about the Stk library.
>> Say I use one of the generator classes
>> 
>> SineWave sine;
>> sine.setFrequency(...)
>> 
>> I don't see where is the SineWave instance err..instanced, like
>> 
>> SineWave sine = new SineWave();
>> 
>> as those are not class methods but instance methods. Is the sine 
>> constructed
>> just by declaring it?
>> Am I lost somewhere?
>> 
>> Thanks in advance...
>> Josep M
>
> _______________________________________________
> Stk mailing list
> Stk@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>