News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

how to implement by own header file?

Started by jdswift, May 23, 2017, 06:40:13 AM

Previous topic - Next topic

jdswift

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

BlueHazzard

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

jdswift

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


jdswift

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