static objet and how to see its value

A

asetofsymbols

Hi
i'm new to c++ i have the class num for big unsigned numbers
it seems work ok until now and i want extend the numbers to big-signed
and big-float

typedef struct{
unsigned len;
unsigned* n;
}num_;

/* big integer unsigned */
class num{
friend int operator==(const num& a, const num& b);
.............................
friend num& operator+(const num& a, const num& b);
.............................
friend num& operator+(const num& a, unsigned b);
.............................
public:
num();
num(double);
num(num&r );
.............
private:
num_ numer;
unsigned lm;
}

// i have write a the definition of class snum
// big integer signed
class snum{
public:
snum();
snum(double);
snum(num&r );
.............
private:
num sn;
int sign;
}

// i have written a definition of class fnum
// big float
class fnum{
public:
fnum();
fnum(double);
fnum(num&r );
.............
private:
snum fn;
unsigned fdigit;
}

Do you see some better way to build the classes fnum and snum by class
num?(and why)

then i have a little problem i have something like
static fnum z[10];
i have the need to write
num g("444555");
z[1].nf.ns=g
or something like
z[1].nf.ns.numer.n[0]=7;
or
z[1].nf.ns.numer.len =7;

*in a function member of num*

and suppose something like

snum& operator+(snum& a, snum& b);
{int j=index();
if(a.sign==1)
{if(b.sign==1)
{z[j].nf.ns.sign= 1; z[j].nf.ns.n= a.ns.n + b.ns.n;}
else if(a.ns.n > b.ns.n)
{z[j].nf.ns.sign= 1; z[j].nf.ns.n= a.ns.n - b.ns.n;}
else {z[j].nf.ns.sign=-1; z[j].nf.ns.n= b.ns.n - a.ns.n;}
}
else {if(b.sign==-1)
{z[j].nf.ns.sign=-1; z[j].nf.ns.n= a.ns.n + b.ns.n;}
else if(a.ns.n > b.ns.n) // b.sign=+1
{z[j].nf.ns.sign=-1; z[j].nf.ns.n= a.ns.n - b.ns.n;}
else {z[j].nf.ns.sign= 1; z[j].nf.ns.n= b.ns.n - a.ns.n;}
}
return z[j].nf.ns
}

How to do it? (compiler says i can not enter from fnum to snum)
Do you see some error?
Thank you
 
A

asetofsymbols

On 4 Jul 2005 10:26:45 -0700, (e-mail address removed) wrote:

yes i have a troll hart
it seems i like the c++ classes but the remain of the language is in
the wrong direction

i have change; i don't know if it work if don't work i use brute force
(assembly)

typedef struct{
unsigned len;
unsigned* n;
}num_;

/* big integer unsigned */
class num{
public:
friend int operator==(const num& a, const num& b);
.............................
friend num& operator+(const num& a, const num& b);
.............................
friend num& operator+(const num& a, unsigned b);
.............................
num();
num(double);
num(num&r );
.............
private:
num_ numer;
unsigned mem;
unsigned fdigit;
}

// i have write a the definition of class snum
// big integer signed
class snum{
public:
snum();
snum(double);
snum(num&r );
.............
private:
num_ numer;
unsigned mem;
unsigned fdigit;
}

// i have written a definition of class fnum
// big float
class fnum{
public:
fnum();
fnum(double);
fnum(num&r );
.............
private:
num_ numer;
unsigned mem;
unsigned fdigit;
}

static fnum z[10];
static snum *zz = (snum*) z;
static num *zzz= (num*) z;

num g("444555");
zzz[1]=g
or something like
zzz[1].numer.n[0]=7;
or
zzz[1].numer.len =7;
*in a function member of num*

and suppose something like
snum& operator+(const snum& a, const snum& b);
{int j=index();
if(a.sign>0)
{if(b.sign>0)
{zz[j].sign= 1; sum_(&zz[j].n, &a.numer, &b.numer);}
in a function of class snum
etc
 
A

asetofsymbols

On 5 Jul 2005 10:37:46 -0700, (e-mail address removed) wrote:
yes i have a troll hart
it seems i like the c++ classes but the remain of the language is in
the wrong direction. Seems that c++ is too much complex (easy thing are
the point of arrive)
and the key word for class seems to me is not 'hide' but 'organize'

i have change;

typedef struct{
unsigned len;
unsigned* n;
}num_;

/* big integer unsigned */
class num{
public:
friend int operator==(const num& a, const num& b);
.............................
friend num& operator+(const num& a, const num& b);
.............................
friend num& operator+(const num& a, unsigned b);
.............................
num();
num(double);
num(num&r );
.............
public:
num_ numer;
unsigned mem;
unsigned fdigit;
}

// i have write a the definition of class snum
// big integer signed
class snum{
public:
snum();
snum(double);
snum(num&r );
public:
num sn;
}

// i have written a definition of class fnum
// big float
class fnum{
public:
fnum();
fnum(double);
fnum(num&r );
public:
num fn;
}

static fnum z[10];
static snum *zz = (snum*) z;
static num *zzz= (num*) z;

num g("444555");
zzz[1]=g
or something like
zzz[1].numer.n[0]=7;
or
zzz[1].numer.len =7;
*in a function member of num*

and suppose something like
snum& operator+(const snum& a, const snum& b);
{int j=index();
if(a.sn.fdigit==0)
{if(b.sn.fdigit==0)
{zz[j].sn.fdigit=0;
sum_( &zz[j].sn.numer, &a.sn.numer, &b.sn.numer); };
in a function of class snum
etc
all is accessible but the it is difficult to do errors with names
becuause they are long in a hierarchy
but why your help is "void"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top