473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Body of a function in a header

My program is heavily template based, and I use the VC++, so I have to keep
the templates in the header file. My .cpp files are quite empty (they are
more a connection between header files). Now, my "problem" is that I can't
put the body of classless functions in the header files. I normally "solve"
this problem using the "inline" keyword (inline functions must be in header
files, but the compiler doesn't have to "inline" inline functions). Is there
a better way to do it? (yes... I know... this is an estetical problem :-) )

Can someone tell me why a class can have the body of the methods "inline" in
the header while a classless function can't? Are there istorical reasons?

--- bye
Jul 22 '05 #1
1 2694
"Massimilia no Alberti" <xa*****@geocit ies.com> wrote...
My program is heavily template based, and I use the VC++, so I have to keep the templates in the header file. My .cpp files are quite empty (they are
more a connection between header files).
This last statement (in parentheses) sounds like a bad idea to me. If your
headers have to be included in a certain order or in order to work some of
your headers require a translation unit to include other headers, it's bad.
If you need something in a header, include the other header in that header.
Now, my "problem" is that I can't
put the body of classless functions in the header files. I normally "solve" this problem using the "inline" keyword (inline functions must be in header files, but the compiler doesn't have to "inline" inline functions). Is there a better way to do it? (yes... I know... this is an estetical problem :-) )
Can someone tell me why a class can have the body of the methods "inline" in the header while a classless function can't?
Nonsense. You may declare any function 'inline' as long as you provide the
function body right there for the compiler to use.
Are there istorical reasons?


I think you're a bit confused there.

inline void foo() { } // doesn't matter where you put this

int main() {
foo();
}

Victor
Jul 22 '05 #2

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

Similar topics

3
1839
by: Kevin Frey | last post by:
Hello, Let's say I have the following: template< class T > class MyClass { void Func( ); }; and I want to declare a specialisation for Func( ) in the presence of
6
1951
by: Sentinel | last post by:
how can i place a script in body (it must be ran automaticly when html interpreter reaches it) that will redirect to another page? what i am doing is checking in php if login is successful (php script is in javascript that is in body) and if so i will print out the url to wich the javascript must redirect the browser
9
19150
by: bmgz | last post by:
I need to execute a JavaScript function "onload". The only problem is I don not have access to the <body> tag as it is a part of the standard page-header include (a separate file). How could I have certain pages execute my function() onLoad? The function basically just sets the original values of fields so that I can determine if a field has been changed or not, which aleviates unnec. sql update on the backend..
11
24082
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on screen. There are a number of solutions available. For example, http://www.litotes.demon.co.uk/example_scripts/tableScroll.html I'm just wondering if anyone knows of a "latest and greatest" script to solve this problem. My requirement at the...
5
1808
by: 2291980 | last post by:
Hello can any body tell me the dff between function redirect($url) { echo "<script>"; echo "window.location='".$url."'"; echo "</script>";
0
948
by: Spam Catcher | last post by:
Hi all, The client is sending a SOAP body with the following information: <soap:Body> <MyFunction xmlns="http://mycompany/services/t1"> <header> ... Custom Elements Here </header>
2
1834
by: urbanedge | last post by:
I've just acquired a site and uploaded to godaddy and the email function won't work. I'm new to php and I'm not able to determine where the issue is. I've commented out $this->header .= $this->body; and I get a blank email to send. I've stripped down the body file but there still seems to be a problem. I'm not sure where to look now. This is the body file. <?php /******************** EMAIL ***************************/ $sRuta =...
0
8761
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,...
1
9200
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,...
0
8144
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
6722
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
6016
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
4525
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...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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
3
2162
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.