473,670 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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==(cons t 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.le n =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

Jul 23 '05 #1
2 1389
On 4 Jul 2005 10:26:45 -0700, as***********@y ahoo.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==(cons t 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

Jul 23 '05 #2
On 5 Jul 2005 10:37:46 -0700, as***********@y ahoo.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==(cons t 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"

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2884
by: crjjrc | last post by:
Hi, I've got a base class and some derived classes that look something like this: class Base { public: int getType() { return type; } private: static const int type = 0; };
3
5846
by: Steve Folly | last post by:
Hi, I had a problem in my code recently which turned out to be the 'the "static initialization order fiasco"' problem (<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>) The FAQ section describes a solution using methods returning references to static objects. But consider:
9
8883
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've *defined* "x"'s value to be 10, isn't above statement a
16
3000
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; class Test { static Test t; static Test init_Test( ) { return t; }
8
2453
by: jayaramganapathy | last post by:
Hello friends, I have a map like std::map< std::string , std::map<std::string, std::string>* EpPropCache::propertyCache ; (This is a static instance and taken from *.cpp file) As you can see the value is a pointer to another map. I do new of std::map<std::string, std::stringand add the pointer to the map. Do I have to delete the map objects which I create with new , which I
5
2498
by: Michael Oswald | last post by:
Hello all, I'm working on a project where I came across some situations, where the GUI library works with normal C callbacks. The code has been implemented by many people, so I came across different versions of callbacks (see the code below for 3 variants). Variant1: a normal static member function is used to redirect the callback to a member function Variant2: a static member function is declared, but at the definition the
5
2002
by: Gernot Frisch | last post by:
// - in my xy.cpp file -- template <const int Ttex, const int Tcol, const int Tlight, int TzBuffer> struct MyFragmentShader { static const int varying_count = Ttex*2 + Tcol*3 + Tlight; }; ....
15
7855
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
1
3371
by: flowstudioLA | last post by:
I have a template class object that I use as a mesaging queue between threads. I use it as a static object that I initialize like so: foo.h class foo{ static LFQueue<const char*,100lfqMyQueue; }; foo.cpp LFQueue<const char*,100Foo::lfqMyQueue;
5
3775
by: chgans | last post by:
Hi all, I'm having difficulties with some template static member, especially when this member is a template instance, for example: ---- template<typename T> class BaseT { public: static void UseMap (const std::string &key, int value)
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.