Solved

Header files and Pointers

Posted on 2001-06-15
4
176 Views
Last Modified: 2010-04-02
I am a student. This is not an assignment. Do you always have to have a header file in C++? How does the program work if you do not need a header file? I also was hoping someone could send me a good link that explains pointers and maybe linked lists.
0
Comment
Question by:awjackin35
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6195019
See:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20135953

So it seems you and sajid are taking the same class?
0
 

Author Comment

by:awjackin35
ID: 6195061
I already read the answers and sajid question. That is why I asked the question. What about iostream.h, Don't you have to have that header file? I also need a good pointers and LL Tutorial.
0
 
LVL 5

Accepted Solution

by:
garboua earned 75 total points
ID: 6195299
here is a quick and simple tutorial about LL
http://personal.adesso.com/~dkovacs/linklist.html
WElL, you need a header file to tell source code that some kind of a function exists some where and tell the compiler not to panic
you can always tell the compiler about other functions in another source file by using the "extern."  Most people don't do this because it becomes old and just too much work.  you have to remember all funcs and put them in all source code and etc etc etc.
you only need to include iostream if you are using one of its funciton, if not then you don't have to.
hope that helped.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6195633
you need to include header files for the functions you want to use. for example to use cout,cin etc you need to include <iostream.h>, if you had no call for these then you need not include it. you can write your own headers and put constants, function/class declarations etc in them, although you should not include function/class definitions in a header. these are best in a source file and then compiled/linked in with the program.

for example

++++++++myheader.h

#define MY_CONSTANT   1000

class myclass
{
 public:
   void mymember();
}

++++++++mysource.cpp

#include "myheader.h"

void myclass::mymember()
{
 /* some code */
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now