Connecting Tech Pros Worldwide Help | Site Map

static objet and how to see its value

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:50 AM
asetofsymbols@yahoo.com
Guest
 
Posts: n/a
Default static objet and how to see its value

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


  #2  
Old July 23rd, 2005, 05:50 AM
asetofsymbols@yahoo.com
Guest
 
Posts: n/a
Default Re: static objet and how to see its value

On 4 Jul 2005 10:26:45 -0700, asetofsymbols@yahoo.com 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

  #3  
Old July 23rd, 2005, 05:51 AM
asetofsymbols@yahoo.com
Guest
 
Posts: n/a
Default Re: static objet and how to see its value

On 5 Jul 2005 10:37:46 -0700, asetofsymbols@yahoo.com 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"

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.