<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 1.9 &#8212; Header files</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/19-header-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/19-header-files/</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 12:59:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: binod</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-91162</link>
		<dc:creator>binod</dc:creator>
		<pubDate>Tue, 31 Aug 2010 14:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-91162</guid>
		<description>here I tried to link grades.h header files but shows link error so,i copied header file to include directory in dev cpp .then it worked,but it looks so weird, how to link without coping header file to include directory</description>
		<content:encoded><![CDATA[<p>here I tried to link grades.h header files but shows link error so,i copied header file to include directory in dev cpp .then it worked,but it looks so weird, how to link without coping header file to include directory</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: binod</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-91161</link>
		<dc:creator>binod</dc:creator>
		<pubDate>Tue, 31 Aug 2010 14:41:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-91161</guid>
		<description>// grades.h
#include 
using namespace std;

class Grades
{
public:

	// function to prompt for 10 grades using while loop
	void getGrade()
	{
		int total = 0;
		int grade;
		int counter = 1;
		int average = total / 10;
		
		while ( counter &lt;= 10 )
		{
			cout &lt;&gt; grade;
			if (( grade  100 ))
				cout &lt;&lt; &quot;Invalid scoren&quot;;
			else
			{
				total += grade;
				counter++;
			}
		}

		cout &lt;&lt; &quot;nThe average grade is: &quot; &lt;&lt; total / 10 &lt;&lt; &quot;n&quot;;
	}
}; // end class

#include 
#include &quot;grades.h&quot;
using namespace std;

int main()
{
	Grades myGrades; // create an object of class Grades
	myGrades.getGrade(); // call the member function of object myGrades
	system(&quot;pause&quot;);
	return 0;
}
here I tried to link grades.h header files but shows link error so,i copied header file to include directory in dev cpp .then it worked,but it looks so weird, how to link without coping header file to include directory</description>
		<content:encoded><![CDATA[<p>// grades.h<br />
#include<br />
using namespace std;</p>
<p>class Grades<br />
{<br />
public:</p>
<p>	// function to prompt for 10 grades using while loop<br />
	void getGrade()<br />
	{<br />
		int total = 0;<br />
		int grade;<br />
		int counter = 1;<br />
		int average = total / 10;</p>
<p>		while ( counter &lt;= 10 )<br />
		{<br />
			cout &lt;&gt; grade;<br />
			if (( grade  100 ))<br />
				cout &lt;&lt; &quot;Invalid scoren&quot;;<br />
			else<br />
			{<br />
				total += grade;<br />
				counter++;<br />
			}<br />
		}</p>
<p>		cout &lt;&lt; &quot;nThe average grade is: &quot; &lt;&lt; total / 10 &lt;&lt; &quot;n&quot;;<br />
	}<br />
}; // end class</p>
<p>#include<br />
#include &#8220;grades.h&#8221;<br />
using namespace std;</p>
<p>int main()<br />
{<br />
	Grades myGrades; // create an object of class Grades<br />
	myGrades.getGrade(); // call the member function of object myGrades<br />
	system(&#8220;pause&#8221;);<br />
	return 0;<br />
}<br />
here I tried to link grades.h header files but shows link error so,i copied header file to include directory in dev cpp .then it worked,but it looks so weird, how to link without coping header file to include directory</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: binod</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-91160</link>
		<dc:creator>binod</dc:creator>
		<pubDate>Tue, 31 Aug 2010 14:36:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-91160</guid>
		<description>class algebra
{
     
      public:
             int add(int  ,int );
             
                
                 
                 
}
 int algebra::add(int a,int b)
 {
     return (a+b);
     }
          

#include
#ifndef &quot;algehra.h&quot;
#include &quot;algebra.h&quot;
using namespace std;
int main()
{
    int a,b;
    cin&gt;&gt;a&gt;&gt;b;
    algebra aa;
    
    cout&lt;&lt;&quot;addtioon=&quot;;
    aa.add(a,b);
    system(&quot;pause&quot;);
    return 0;
}
#endif</description>
		<content:encoded><![CDATA[<p>class algebra<br />
{</p>
<p>      public:<br />
             int add(int  ,int );</p>
<p>}<br />
 int algebra::add(int a,int b)<br />
 {<br />
     return (a+b);<br />
     }</p>
<p>#include<br />
#ifndef &#8220;algehra.h&#8221;<br />
#include &#8220;algebra.h&#8221;<br />
using namespace std;<br />
int main()<br />
{<br />
    int a,b;<br />
    cin&gt;&gt;a&gt;&gt;b;<br />
    algebra aa;</p>
<p>    cout&lt;&lt;&quot;addtioon=&quot;;<br />
    aa.add(a,b);<br />
    system(&quot;pause&quot;);<br />
    return 0;<br />
}<br />
#endif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Johnson</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-91136</link>
		<dc:creator>Jeff Johnson</dc:creator>
		<pubDate>Tue, 31 Aug 2010 02:35:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-91136</guid>
		<description>&lt;pre&gt;
ADD.h
#ifndef ADD_H
#define ADD_H

int add(int x, int y); // function prototype for add.h

#endif

ADD.cpp
#include &lt;iostream&gt;


int add(int x, int y)
{
    return x + y;
}

main.cpp
#include &lt;iostream&gt;
#include &quot;ADD.h&quot; // this brings in the declaration for add()

int main()
{
    using namespace std;
    cout &lt;&lt; &quot;The sum of 3 and 4 is &quot; &lt;&lt; add(3, 4) &lt;&lt; endl;
    cin.clear();
    cin.ignore(255, &#039;\n&#039;);
    cin.get();
	return 0;
}
&lt;/pre&gt;

I&#039;m getting this error 

Compiler: Default compiler
Building Makefile: &quot;C:\Dev-Cpp\Makefile.win&quot;
Executing  make...
make.exe -f &quot;C:\Dev-Cpp\Makefile.win&quot; all
g++.exe -c ADD.cpp -o ADD.o -I&quot;C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include&quot;  -I&quot;C:/Dev-Cpp/include/c++/3.4.2/backward&quot;  -I&quot;C:/Dev-Cpp/include/c++/3.4.2/mingw32&quot;  -I&quot;C:/Dev-Cpp/include/c++/3.4.2&quot;  -I&quot;C:/Dev-Cpp/include&quot;   

g++.exe main.o ADD.o  -o &quot;Project1.exe&quot; -L&quot;C:/Dev-Cpp/lib&quot;  

ADD.o(.text+0x100):ADD.cpp: multiple definition of `add(int, int)&#039;
main.o(.text+0x100):main.cpp: first defined here
collect2: ld returned 1 exit status

make.exe: *** [Project1.exe] Error 1

Execution terminated

I&#039;m using bloodshed</description>
		<content:encoded><![CDATA[<pre>
ADD.h
#ifndef ADD_H
#define ADD_H

int add(int x, int y); // function prototype for add.h

#endif

ADD.cpp
#include &lt;iostream&gt;

int add(int x, int y)
{
    return x + y;
}

main.cpp
#include &lt;iostream&gt;
#include &quot;ADD.h&quot; // this brings in the declaration for add()

int main()
{
    using namespace std;
    cout &lt;&lt; &quot;The sum of 3 and 4 is &quot; &lt;&lt; add(3, 4) &lt;&lt; endl;
    cin.clear();
    cin.ignore(255, &#39;\n&#39;);
    cin.get();
	return 0;
}
</pre>
<p>I&#8217;m getting this error </p>
<p>Compiler: Default compiler<br />
Building Makefile: &#8220;C:\Dev-Cpp\Makefile.win&#8221;<br />
Executing  make&#8230;<br />
make.exe -f &#8220;C:\Dev-Cpp\Makefile.win&#8221; all<br />
g++.exe -c ADD.cpp -o ADD.o -I&#8221;C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include&#8221;  -I&#8221;C:/Dev-Cpp/include/c++/3.4.2/backward&#8221;  -I&#8221;C:/Dev-Cpp/include/c++/3.4.2/mingw32&#8243;  -I&#8221;C:/Dev-Cpp/include/c++/3.4.2&#8243;  -I&#8221;C:/Dev-Cpp/include&#8221;   </p>
<p>g++.exe main.o ADD.o  -o &#8220;Project1.exe&#8221; -L&#8221;C:/Dev-Cpp/lib&#8221;  </p>
<p>ADD.o(.text+0&#215;100):ADD.cpp: multiple definition of `add(int, int)&#8217;<br />
main.o(.text+0&#215;100):main.cpp: first defined here<br />
collect2: ld returned 1 exit status</p>
<p>make.exe: *** [Project1.exe] Error 1</p>
<p>Execution terminated</p>
<p>I&#8217;m using bloodshed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: help with Eclipse (project)</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-89644</link>
		<dc:creator>help with Eclipse (project)</dc:creator>
		<pubDate>Thu, 05 Aug 2010 00:21:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-89644</guid>
		<description>[...] used it before, and I wanted to create a project like this  main.cpp add.h  Here is the example. Learn C++ -   I created a project, added add.h and main.cpp I am sure if I was doing it right: I do build but [...]</description>
		<content:encoded><![CDATA[<p>[...] used it before, and I wanted to create a project like this  main.cpp add.h  Here is the example. Learn C++ &#8211;   I created a project, added add.h and main.cpp I am sure if I was doing it right: I do build but [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: poornima</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-89392</link>
		<dc:creator>poornima</dc:creator>
		<pubDate>Sun, 01 Aug 2010 02:00:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-89392</guid>
		<description>Is it possible to use $ sign in the place of angular brackets in the header files section.
ex:#include$stdio.h$ instead of general usage of 
#include
#include&quot;stdio.h&quot;</description>
		<content:encoded><![CDATA[<p>Is it possible to use $ sign in the place of angular brackets in the header files section.<br />
ex:#include$stdio.h$ instead of general usage of<br />
#include<br />
#include&#8221;stdio.h&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: akhileshr7</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-89359</link>
		<dc:creator>akhileshr7</dc:creator>
		<pubDate>Sat, 31 Jul 2010 13:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-89359</guid>
		<description>Thanks Alex! Nice tutorial.

I&#039;m learning c++ and having tough time compiling the following code. Can some please help?

This is the error i&#039;m getting - 

$ c++ main.cpp
/tmp/ccKDQaIR.o(.text+0x128): In function `main&#039;:
: undefined reference to `add(int, int)&#039;
collect2: ld returned 1 exit status

This is my code - 

main.cpp
&lt;pre&gt;
#include &lt;iostream&gt;
#include &quot;add.h&quot;

int main() {
        std::cout &lt;&lt; &quot;Sum of 3 and 4 is : &quot; &lt;&lt; add(3,4) &lt;&lt; std::endl;
}
&lt;/pre&gt;

add.h
&lt;pre&gt;
#ifndef GUARD_add_h
#define GUARD_add_h

int add(int, int);

#endif
&lt;/pre&gt;

add.cpp
&lt;pre&gt;
#include &quot;add.h&quot;

int add(int a, int b) {
        return (a + b);
}
&lt;/pre&gt;

This is the version of my c++ compiler - 
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)

Thanks!</description>
		<content:encoded><![CDATA[<p>Thanks Alex! Nice tutorial.</p>
<p>I&#8217;m learning c++ and having tough time compiling the following code. Can some please help?</p>
<p>This is the error i&#8217;m getting &#8211; </p>
<p>$ c++ main.cpp<br />
/tmp/ccKDQaIR.o(.text+0&#215;128): In function `main&#8217;:<br />
: undefined reference to `add(int, int)&#8217;<br />
collect2: ld returned 1 exit status</p>
<p>This is my code &#8211; </p>
<p>main.cpp</p>
<pre>
#include &lt;iostream&gt;
#include &quot;add.h&quot;

int main() {
        std::cout &lt;&lt; &quot;Sum of 3 and 4 is : &quot; &lt;&lt; add(3,4) &lt;&lt; std::endl;
}
</pre>
<p>add.h</p>
<pre>
#ifndef GUARD_add_h
#define GUARD_add_h

int add(int, int);

#endif
</pre>
<p>add.cpp</p>
<pre>
#include &quot;add.h&quot;

int add(int a, int b) {
        return (a + b);
}
</pre>
<p>This is the version of my c++ compiler &#8211;<br />
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kraig</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-88946</link>
		<dc:creator>Kraig</dc:creator>
		<pubDate>Fri, 23 Jul 2010 02:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-88946</guid>
		<description>For those of you who are using Visual Studio and are getting errors. This will fix it!!

First off you don&#039;t need add.cpp, because add.h is your&quot;library for the function&quot;
-If you are following along with the tutorial you need to edit the add.h file.
-It needs to be as follows:
     &lt;pre&gt;#ifndef ADD_H
     #define ADD_H

     int add(int x, int y) // function prototype for add.h
     {
        return x + y;  // without this the function doesn&#039;t know what you want it to do
     }


      #endif&lt;/pre&gt;


Reason for the change...a function must be declared in order to work.</description>
		<content:encoded><![CDATA[<p>For those of you who are using Visual Studio and are getting errors. This will fix it!!</p>
<p>First off you don&#8217;t need add.cpp, because add.h is your&#8221;library for the function&#8221;<br />
-If you are following along with the tutorial you need to edit the add.h file.<br />
-It needs to be as follows:</p>
<pre>#ifndef ADD_H
     #define ADD_H

     int add(int x, int y) // function prototype for add.h
     {
        return x + y;  // without this the function doesn&#39;t know what you want it to do
     }

      #endif</pre>
<p>Reason for the change&#8230;a function must be declared in order to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dax</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-88777</link>
		<dc:creator>dax</dc:creator>
		<pubDate>Tue, 20 Jul 2010 11:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-88777</guid>
		<description>In &quot;add.h&quot; add a semicolon at the end of the function declaration:
&lt;pre&gt;
int add(int x, int y);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>In &#8220;add.h&#8221; add a semicolon at the end of the function declaration:</p>
<pre>
int add(int x, int y);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Beaugarcia.com &#124; Resources &#187; C++ &#8211; header files explained</title>
		<link>http://www.learncpp.com/cpp-tutorial/19-header-files/comment-page-2/#comment-88431</link>
		<dc:creator>Beaugarcia.com &#124; Resources &#187; C++ &#8211; header files explained</dc:creator>
		<pubDate>Wed, 14 Jul 2010 12:40:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=32#comment-88431</guid>
		<description>[...] http://www.learncpp.com/cpp-tutorial/19-header-files/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://www.learncpp.com/cpp-tutorial/19-header-files/" rel="nofollow">http://www.learncpp.com/cpp-tutorial/19-header-files/</a> [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
