I have some doubts about what is the best method to distribute classes in .cpp and .h files:
- Should I use a file per class? or should I group similar classes in one file?
- Is it good to put a lot of class declarations in the same .h, and their definitions in different .cpps?
- And, to the contrary, many definitions in one cpp and declarations in different .h?
- How to deal with precompiled headers? is it ok to include all headers in the precompiled header and include it
everywhere you need?.
- What impact does all this have in the executable size (if any)?
- Is there any document or URL with advice on all these?.
Thank you,
Javier Sanz. 3 2559
Depends ...
If you map header:class=1: 1 :) than other classes can use another ones, so
you must include file(s) in include file (some things are posted recently
about this).
My method is: if classes are not too large and not depend too much on
another clases than i write 1:1 (there is tiny line beatween this).
Execuatble size will not be shorter/bigger if you use any methode, it
depends on implementation of clases.
Grouping all classes in one HUGE header is not good practice, particulary
if you write some stuff to use letter (imagine that all STL are in one
header - it will need a lot of minutes to compile).
All of this is my aprouch, so it will not be the best!
Best,
Zaharije Pasalic
Javi <mispamaki@_ANT I-SPAM_ya.com> writes: I have some doubts about what is the best method to distribute classes in .cpp and .h files:
- Should I use a file per class? or should I group similar classes in one file? - Is it good to put a lot of class declarations in the same .h, and their definitions in different .cpps? - And, to the contrary, many definitions in one cpp and declarations in different .h?
Personaly I put one class prototype in one .h (myclass.h for ex) and 1
description of 1 class in 1 cpp (myclass.cpp for example)
- How to deal with precompiled headers? is it ok to include all headers in the precompiled header and include it everywhere you need?. - What impact does all this have in the executable size (if any)?
Nothing, because when the compiler works, you can imagine it works on
one bigger file whow contains all your files (it's very imaging)
- Is there any document or URL with advice on all these?.
Thank you,
Javier Sanz.
Sorry for my english, if you have the time and if you are brave, don't
hesitate to correct me, thx ;)
Bye
--
e-Jah
L'expansion de l'univers est un coredump en cours...
( http://quadaemon.free.fr/tribune.fortune)
Javi wrote: I have some doubts about what is the best method to distribute classes in source (*.cpp) and header (*.h) files:
- Should I use a file per class? - Or should I group similar classes in one file?
Your program should be decomposed into *modules*
which consist of compile time class library (header files)
and runtime (static and/or dynamic) class library archives.
The header files describe the module *interface*.
The source files describe the module *implementation *.
It is probably best to decompose modules
into the smallest possible useful units
so that you can re-use the sub-modules in other modules.
- Is it good to put a lot of class declarations in the same header file and their definitions in different source files? - And, to the contrary, many definitions in one source file and declarations in different header files?
Not generally.
Usually, it is better to create separate header files
and include them in other header files to improve "modularity ".
- How to deal with precompiled headers? Is it ok to include all headers in the precompiled header and include it everywhere you need?
This tends to defeat the purpose of precompiled headers.
- What impact does all this have in the executable size (if any)? - Is there any document or URL with advice on all these?.
This depends upon your implementation.
Generally, it is better to keep source files
(and the object code files produced from them)
as small as possible so that your link editor
can extract exactly the functions that it needs
from the library archive. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ed Landau |
last post by:
Hi: I've just developped a really simple MS Access App. The VBA runs
within the database. It uses some DLLs which I register with a script.
It's on MS Access2003 (Office11). I've got 2003Pro but could get Ent.
Never having done this before, I'm not sure what I need to do in order to be
able to distribute it. I'd like not to require other users to have Access
installed (let alone 2003). For starters, I'm just looking to be able...
|
by: Wiktor Zychla |
last post by:
is it legal to distribute axshdocvw, shdocvw and mshtml.dll with my
application?
is it legal to distribute Microsoft.mshtml.dll from 'Primary Interop
Assemblies' folder (I assume it comes with Visual Studio)?
thanks for any clues,
Wiktor Zychla
|
by: Darius |
last post by:
How to distribute a C program into many C files ?
this is the first question a C programmer asks after learning C basics,
Questions like
--what is a header file
--where should i put global variables
--where should i put declaration and definitions
--where should i put macros
--when to use static functions and variables
|
by: Yogi_Bear_79 |
last post by:
I recently some embedded GZIP files into my project. I added the
sharpziplib.dllas a referance. But when I distribute the .exe it looks for
the .dll. Did I do something wrong, or miss step? I don't want to have to
distribute the .dll, I was hoping to continue this as a stand alone .exe
|
by: Danny J. Lesandrini |
last post by:
Didn't get any takers on this post this morning at dotnet.General, so I'm
reposting here.
First, this is _not_ a question about how to get Crystal Reports to run
on a client machine. I've got all the merge modules added to the project
and it's working fine. The question is about distributing my .RPT files.
1) Initial Setup Project inclusion of .rpt files:
My folder of new .RPT files keeps growing. Is there a way to point
| |
by: mike7411 |
last post by:
Is there an easy way to tell which files I need to distribute with
my Microsoft Visual Studio 2005 MFC application?
I keep getting a vague message on my target computer saying
the application configuration is incorrect.
|
by: Bob Alston |
last post by:
Is it considered best practice to distribute FE databases as MDEs rather
than MDBs? Without flaming me for asking the question, could someone
please enumerate the key advantages?
Also I like to provide my users a mini report writer where the report
specs are stored as local data files. Can I do this in an MDE - e.g.
have local data files for the report writer spec but no queries, forms
or report changes?
Thanks.
|
by: akbar |
last post by:
Hi,
I am creating not-so-important opensource application written in python
for Linux. I have two files python source in src directory, named
blabla1.py and blabla2.py. There are byte compiled files too, named
blabla1.pyc and blabla2.pyc. Should I distribute these files (pyc
files) to users? If I don't distribute them, and user installed my
application into /usr (not writable by normal user) then run it as
normal user, off course, the...
|
by: Neil Chambers |
last post by:
I am working in VS2008 and my website has a corresponding solution file in a
different directory. I want other people to be able to work on this project
from a version control system but I am missing a piece of the puzzle. My
site (classes, aspx files etc) have been submitted to revision control but
my colleagues can't work on them due to a missing solution file.
1. what is the best way to ensure all appropriate files are put under source...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |