Author Topic: how to implement by own header file?  (Read 213 times)

Offline jdswift

  • Single posting newcomer
  • *
  • Posts: 3
how to implement by own header file?
« on: May 23, 2017, 06:40:13 am »
greetings, i am new to C++ programming, though I am an experienced programmer .

i have entered my own user-created header in the programming workspace before my C++ functions, but when I try to build (compile and link) the compiler says cannot find the header file.

I probably need the save the header code separately, which I tried to do with a .h file extension, but that does not work.

any suggestions would be appreciated.  i can insert my header and functions (they are not very long) in the body of a mesage if that is helpful.

Thanks a million,

David
Western NY

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1346
Re: how to implement by own header file?
« Reply #1 on: May 23, 2017, 08:26:56 pm »
Honestly i have no idea what you are talking about, but a view suggestions:

1) Always use projects
2) To create a header in your project: File->New File->C/C++ header
3) To add a existing file to your project: Project->Add file

If you have problems with compiling:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Offline jdswift

  • Single posting newcomer
  • *
  • Posts: 3
Re: how to implement by own header file?
« Reply #2 on: May 24, 2017, 04:49:18 am »
Thanks, Blue,

I am not surprised by your initial comment, because the 2006 book I am studying "C++ for Mathematicians" by Edward Scheinerman is vague about this (p.73-75).

Your suggestions are very helpful, especially 2 and 3.  I have been following number 1, thank you!

May I ask another one of you?

I have written a simple program that writes a file.  I specify the name of the file like this "poop1" and it runs fine, creating the file and allowing me to open and read it subsequently.

But, when I tried to allow the user to enter a file name as a string, the compiler balks.

I can send the code if that helps.

With appreciation for your time and expertise,

David
Western NY


Offline jdswift

  • Single posting newcomer
  • *
  • Posts: 3
Re: how to implement by own header file?
« Reply #3 on: May 24, 2017, 05:12:29 am »
Hi, again,

It worked.  Your suggestion #2 did the trick, many thanks!  #3 looks like it would have worked, also.

It's a very nice program.  It prints out the prime factorization of all positive integers from 1 to 100 (or a higher number, as you wish)

I am a numbers guy and factoring positive integers is a fun exercise!

What are your hobbies and/or interests, if you feel like saying?
 
Good Night,

David
Physics lecturer
State University of New York at Fredonia



Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1346