come ad esempio nel seguente codice, avrei voluto una variabile publica const relativa all'istanza che tornasse il risultato di un'operazione su i parametri del costruttore, ma posso solo fare così:
codice:
#include <stdio.h>
#include <stdlib.h>
// Declare Class
class marameo
{
public:
marameo();
marameo(int, short, short);
int suggested(void);
private:
int _dwSamplePerSec;
short _wBitsPerSample;
short _nChannels;
};
int main()
{
// Use Class
marameo* C = new marameo();
printf("%d\n", C->suggested());
system("pause");
return EXIT_SUCCESS;
}
// Define Class
marameo::marameo()
:
_dwSamplePerSec(44100),
_wBitsPerSample(16),
_nChannels(2)
{ }
marameo::marameo(const int dwSamplePerSec, const short wBitsPerSample, const short nChannels)
:
_dwSamplePerSec(dwSamplePerSec),
_wBitsPerSample(wBitsPerSample),
_nChannels(nChannels)
{ }
int marameo::suggested(void)
{
return (int)(_dwSamplePerSec * ((_nChannels * _wBitsPerSample) / 8));
}