473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Define Object

An object can be defined using a class. The class contains variables
and functions. It has a pointer to bind variables and functions. If I want
to create more than one object. The class can have two objects with a
separate pointer. However, functions are always shared with one or more
objects, but each object has its own separate variables. It allows to
reduce unreadable messy source code and bugs.
However, I do not want to use a pointer to bind variables and functions
inside class, otherwise, it can degrade performance. Procedural Oriental
Programming is only the solution. This allows global variables and global
functions to be placed inside namespace on one module like one header
inside.
If I want to define more than one object, I can create an array of each
global variables. The global functions can always be shared with array of
variables. After all global variables and global functions are defined
inside namespace on one module, the module can become a header file. Few
functions use extern keyword so it can be used to all module of C++ source
code. All global functions and global variables do not have extern keyword
so they will be inaccessible to all moudle of C++ source code.
Please convince me if you think is best to advise. Should I use
Procedural Oriental Programming or Object Oriental Programming. I plan to
put one module into DLL. This allows the programmers to use my DLL to
access resuable global functions when they want to create one or more
objects. They will not be able to see inaccessible global variables and
global functions. It helps to keep source code clean.
Please let me know what you think and try to suggest what I should
design object using POP or OOP.
Here is an example.

Module #1
// foo.h
#ifndef FOO_H
#define FOO_H

namespace foo
{
extern int Object_Count;
extern int Run(void); // accessible to all modules
} // foo

#endif
// foo.cpp

namespace foo
{
int Object_Count = 0;
int g_a[5] = 0; // global variables are private
int g_b[5] = 0;
int g_c[5] = 0;

// Three functions below are private.

void A(void)
{
g_a[Object_Count] += 1;
}

void B(void)
{
g_b[Object_Count] += 2;
}

void C(void)
{
g_c[Object_Count] += 4;
}

// Public
int Run(void)
{
if (Object_Count 5)
return -1; // Exceed Object_Count limit and return failed.

A();
B();
C();
}
} // foo

Moudle #1
// Main.cpp
#include "foo.h"

int main(void)
{
foo::Object_Count = 0;
foo::Run();

foo::Object_Count = 1;
foo::Run();

foo::g_a = 5; // Error without extern keyword so it is private
foo::A(); // Error without extern keyword so it is private
}
--

Yours Truly,
Bryan Parkoff
Dec 29 '07 #1
1 2654

"Bryan Parkoff" <no****@nospam.comwrote in message
news:47**********************@roadrunner.com...
An object can be defined using a class. The class contains variables
and functions.
It has a pointer to bind variables and functions. If I want to create
more than one object. The class can have two objects with a separate
pointer.
Says who? What class? All classes? Are you trying to dictate what a class is
or what your planned implementation is?
However, functions are always shared with one or more objects,
What do you mean shared? How is it "shared"?
but each object has its own separate variables.
I'd hope so.
It allows to reduce unreadable messy source code and bugs.
What is "it?"
However, I do not want to use a pointer to bind variables and functions
inside class, otherwise, it can degrade performance.
What do you mean "bind"? How is performance degraded? And what class are you
talking about?
Procedural Oriental Programming is only the solution.
Solution to what?
This allows global variables and global functions to be placed inside
namespace on one module like one header inside.
What is "this"?
If I want to define more than one object, I can create an array of each
global variables.
Sure... a variable is an object after all.
The global functions can always be shared with array of variables.
What do you mean shared? shared with whom and how? What does an array have
to do with it?
After all global variables and global functions are defined inside
namespace on one module, the module can become a header file.
No matter what you are talking about, this is _probably_ a bad idea. But, I
don't know what you are talking about.
Few functions use extern keyword so it can be used to all module of C++
source code.
What? What is "it"? "used to all module"? huh?
All global functions and global variables do not have extern keyword so
they will be inaccessible to all moudle of C++ source code.
Are you trying to say that functions and variables that are not declared to
be extern are not visible outside your module?
Please convince me if you think is best to advise.
I think it is best you seek advise rather than advise.
Should I use Procedural Oriental Programming or Object Oriental
Programming.
I dunno. You haven't said what you are trying to accomplish.
I plan to put one module into DLL. This allows the programmers to use my
DLL to access resuable global functions when they want to create one or
more objects.
I don't know what having one module has to do with anything else in that
paragraph.
They will not be able to see inaccessible global variables and global
functions. It helps to keep source code clean.
Not exposing some variables and functions outside your .dll keeps source
code clean? I'd better tell some of my messy co-workers.
Please let me know what you think and try to suggest what I should design
object using POP or OOP.
I think I have no idea what you are asking. I suggest you design a program,
but you already objected.

Here is an example.
Of what?
<snip>

I'd love to help, but I cannot begin to decypher the incomplete sentences
you posted. Even if english is your second language, the post doesn't make
enough sense for me to determine what the question is. Do you want to know
why something you are designing would be better done OOP vs Procedural? What
are you trying to accomplish? What is your .dll supposed to do?

Dec 29 '07 #2

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

Similar topics

97
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
6
by: Peng Yu | last post by:
I want to define a macro #define FILEWR(FILENAME) which can be expanded to #ifndef OUTFILE #define OUTFILE ofstream out; #endif
18
by: Bryan Parkoff | last post by:
"#define" can only be inside the global scope before main() function. "#if" can be tested after "#define" is executed. The problem is that "#define" can't be inside main() function. I do not wish...
18
by: MakisGR | last post by:
I'm having trouble understanding what the following define does. Can anyone provide some assistance? #define SetBits(bits,pos) (((bits)) |= (1 << ((pos) & 7))) -- comp.lang.c.moderated -...
42
by: baumann | last post by:
hi all, typedef int (*pfunc)(int , int); pfunc a_func; i know it's ok, but how can define a_func without typedef statement? thanks .
18
by: **Developer** | last post by:
I always define events with the parameters ByVal sender As Object, ByVal e As EventArgs Even if they are not used. Seems I read someplace that's the thing to do. So I then do:
5
by: eiji | last post by:
Hi folks, I hope this is not "off topic"! :-) Consider the next code: /* Declarations of types that could become platform-dependent */ #define MyChar char #define MyInt int
6
by: raghu | last post by:
#define GOOGLE int main(void) { printf("%d",GOOGLE); return 0; } In the above program ,by default GOOGLE should be assigned to zero..right? But when I try to print it it gives an error at...
5
by: alan | last post by:
Hello world, I'm wondering if it's possible to implement some sort of class/object that can perform mapping from class types to strings? I will know the class type at compile time, like so:...
1
by: sophia | last post by:
Dear all, the following are the differences b/w #define and typedef ,which i have seen in Peter van der lindens book. is there any other difference between thes two ? The right way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.