473,804 Members | 3,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Cou nt = 0;
foo::Run();

foo::Object_Cou nt = 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 2685

"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
27824
by: s | last post by:
Can I do this: #define MYSTRING "ABC" .. .. .. char mychar = MYSTRING; .. .. ..
6
3173
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
8930
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 to create multiple functions which they look almost identical in C++ source code. The C++ compiler should be able to compile one Test() function into two almost identical functions before they are translated into the machine language object. ...
18
1483
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 - moderation address: clcm@plethora.net
42
5635
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
1455
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
3615
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
1880
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 printf
5
2577
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: const char *s = string_mapper<thetype>(); However I do not know the string to be associated with the type at compile time, and will need a way to set up the mapping, to be created at run time, possibly like so: void foo(char*...
1
5226
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 think about typedef as being a complete encapsulated type - you can't add to it after you have declared it.
0
9704
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
9572
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
10562
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
10070
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
9132
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...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2978
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.