Can a ctor be declared inline ?
Is it not declared inline to avoid executable code size becoming
huge ?
kindly clarify
Thanks
V.Subramanian 12 1744
On Thu, 22 Nov 2007 23:53:29 -0800 (PST), su************* *@yahoo.com wrote:
Can a ctor be declared inline ?
Yes.
Is it not declared inline to avoid executable
code size becoming huge ?
That may be a motive for someone.
--
Joel Yliluoma - http://iki.fi/bisqwit/
On Nov 23, 8:53 am, "subramanian10. ..@yahoo.com, India"
<subramanian10. ..@yahoo.comwro te:
Can a ctor be declared inline ?
Of course.
Is it not declared inline to avoid executable code size
becoming huge ?
Usually, it's not declared inline to avoid unnecessary coupling.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On Nov 23, 10:01 pm, James Kanze <james.ka...@gm ail.comwrote:
On Nov 23, 8:53 am, "subramanian10. ..@yahoo.com, India"
<subramanian10. ..@yahoo.comwro te:
Can a ctor be declared inline ?
Of course.
Is it not declared inline to avoid executable code size
becoming huge ?
Usually, it's not declared inline to avoid unnecessary coupling.
Just curious, but coupling to what? I don't quite understand this.
Isn't the compiler obligated with ensuring that an inlined and non-
inlined function call are for the most part equivalent? To what
degree can an inlined function digress from a non-inlined version?
Or is it because that inline functions must be declared somehow in
each source file that uses the function (in this case a ctor), and
will typically be placed in a header, which arguably is the "wrong"
place to put the details of the code?
On Nov 23, 3:53 pm, "subramanian10. ..@yahoo.com, India"
<subramanian10. ..@yahoo.comwro te:
Can a ctor be declared inline ?
Is it not declared inline to avoid executable code size becoming
huge ?
Note that inlining does not *always* increase executable code size.
It *may* reduce code size; it may increase code size. Please see: http://www.parashift.com/c++-faq-lit...s.html#faq-9.3
On Fri, 23 Nov 2007 06:08:02 -0800, alan wrote:
On Nov 23, 10:01 pm, James Kanze <james.ka...@gm ail.comwrote:
>On Nov 23, 8:53 am, "subramanian10. ..@yahoo.com, India"
<subramanian10 ...@yahoo.comwr ote:
Can a ctor be declared inline ?
Of course.
Is it not declared inline to avoid executable code size becoming huge
?
Usually, it's not declared inline to avoid unnecessary coupling.
Just curious, but coupling to what? I don't quite understand this.
Isn't the compiler obligated with ensuring that an inlined and non-
inlined function call are for the most part equivalent? To what degree
can an inlined function digress from a non-inlined version?
All code which needs to 'see' a class definition has also to 'see' all
inline members. Changing any of them forces recompilation which wouldn't
be necessary if they weren't inline.
--
Tadeusz B. Kopec (tk****@NOSPAMP LEASElife.pl)
Anybody who doesn't cut his speed at the sight of a police car is
probably parked.
On Nov 24, 3:15 am, "Tadeusz B. Kopec" <tko...@NOSPAMP LEASElife.pl>
wrote:
On Fri, 23 Nov 2007 06:08:02 -0800, alan wrote:
On Nov 23, 10:01 pm, James Kanze <james.ka...@gm ail.comwrote:
On Nov 23, 8:53 am, "subramanian10. ..@yahoo.com, India"
<subramanian10. ..@yahoo.comwro te:
Can a ctor be declared inline ?
Of course.
Is it not declared inline to avoid executable code size becoming huge
?
Usually, it's not declared inline to avoid unnecessary coupling.
Just curious, but coupling to what? I don't quite understand this.
Isn't the compiler obligated with ensuring that an inlined and non-
inlined function call are for the most part equivalent? To what degree
can an inlined function digress from a non-inlined version?
All code which needs to 'see' a class definition has also to 'see' all
inline members. Changing any of them forces recompilation which wouldn't
be necessary if they weren't inline.
I see; I suppose I haven't actually been on anything like a big C++
project (possibly involving library-in-binary-format), so I personally
don't care about recompilation; but I suppose this is a good idea, if
ever I get into one.
Tadeusz B. Kopec wrote:
All code which needs to 'see' a class definition has also to 'see' all
inline members. Changing any of them forces recompilation which wouldn't
be necessary if they weren't inline.
It doesn't have to. While defining the function inside the class
definition makes it inline, you can still just use the regular
"inline" keyword and define it elsewhere.
On Sat, 24 Nov 2007 08:16:40 -0500, Ron Natalie wrote:
Tadeusz B. Kopec wrote:
>All code which needs to 'see' a class definition has also to 'see' all inline members. Changing any of them forces recompilation which wouldn't be necessary if they weren't inline.
It doesn't have to. While defining the function inside the class
definition makes it inline, you can still just use the regular "inline"
keyword and define it elsewhere.
3.2.3 An inline function shall be defined in every translation unit in
which it is used.
So that 'elsewhere' usually is in the same header. Other places are hard
to maintain.
--
Tadeusz B. Kopec (tk****@NOSPAMP LEASElife.pl)
There's a way out of any cage.
-- Captain Christopher Pike, "The Menagerie" ("The Cage"),
stardate unknown.
Tadeusz B. Kopec wrote:
On Sat, 24 Nov 2007 08:16:40 -0500, Ron Natalie wrote:
>Tadeusz B. Kopec wrote:
>>All code which needs to 'see' a class definition has also to 'see' all inline members. Changing any of them forces recompilation which wouldn't be necessary if they weren't inline.
It doesn't have to. While defining the function inside the class definition makes it inline, you can still just use the regular "inline" keyword and define it elsewhere.
3.2.3 An inline function shall be defined in every translation unit in
which it is used.
So that 'elsewhere' usually is in the same header. Other places are hard
to maintain.
Nope. Only the places where it is used. Public methods are one
thing, but you said "all inline members" and there's no necessity to
expose them all if they can't be called everywhere the class
definition appears. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rich |
last post by:
Hi,
I have a query regarding VC6 and its handling of templated copy
constructors. Here goes:
Take a look at the following code sample...
template<class _Ty, size_t t_uiSize = 10 >
class my_template
|
by: richardclay09 |
last post by:
The output of this:
#include <iostream>
#include <vector>
using namespace std;
struct X {
int i;
X(const X& x) : i(x.i) {
cout << "ctor copy: " << i << endl;
|
by: hazz |
last post by:
will the third ctor in this class call the first two or just the null ctor?
public class B {
public B() { ... }
public B(string str) {.....}
public B(Token tkn, string str, int int_var) : this() { ... }
}
can I add an argument to this(str) and do the following so that ctor #3 does
call ctor#2 ?
|
by: PasalicZaharije |
last post by:
Hallo,
few days ago I see ctor like this:
Ctor() try : v1(0) {
// some code
}
catch(...) {
// some code
}
|
by: 2005 |
last post by:
Hi
If I have a class,
class CNode {
public:
CarNode() : m_pNext(0), m_ticketNum(0) {}
~CarNode();
private:
| |
by: Grizlyk |
last post by:
Good morning.
Look here:
http://groups.google.com/group/fido7.ru.cpp.chainik/browse_frm/thread/7341aba5238c0f79
and here:
http://groups.google.com/group/fido7.ru.cpp.chainik/browse_frm/thread/cb014f4ba9df614a
Can anybody answer?
Who can't read in russian:
|
by: peifeng_w |
last post by:
Hi, try the following code with flag=0/1/2.
#include<iostream>
using namespace std;
#define flag 2//option:0,1,2
class C
{
|
by: John Salmon |
last post by:
g++ complains about illegal access to a private member
when the following is compiled with a private copy
constructor for the class C. When the copy constructor
is public, the program runs and demonstrates(?) that
the copy constructor is never called (at least no sign
of its chatter on std::cout is visible).
So - is it necessary to have a public copy constructor
in order to use "function style" initializers for an
array of objects? ...
|
by: subramanian100in |
last post by:
If we do not provide any ctor for a class, the compiler provides the
default ctor and copy ctor if needed.
Consider a class Test.
Suppose we provide some ctor in class Test but do not provide the
default ctor.
Suppose we try to create
Test obj;
|
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: 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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |