Your browser (Internet Explorer 7 or lower) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.


A C++ Makefile example

For example, I have the following files:
– tree.h (header file)
– tree.cpp (contains routines)
– tree_proj (contains main() function)

I want to make a Makefile to manage the execution, to create an executable file: proj.

This is the Make file. Note the < TAB > is ‘a tab’ in order for the Makefile to work.

proj : tree_proj.o tree.o
< TAB >g++ -g -o proj tree_proj.o tree.o
tree.o : tree.cpp tree.h
< TAB >g++ -g -c tree.cpp
tree_proj.o : tree_proj.cpp tree.h
< TAB >g++ -g -c tree_proj.cpp
clean :
< TAB >rm *.o proj

After saving this file as Makefile. If there is only Makefile in the directory, then I can simply run it by the command:


Or if there are several makefiles, then I can specify which one to run:

make -f Makefile

A C++ String Assignment: Declination.

This assignment is to read from a standard input a series of lines of Latin nouns and adjectives and to output to the screen their declination.

In many languages, nouns (and adjectives) are declined into a variety of forms [called ”cases”] to show their function in the sentence. In Latin, there are 5 cases: nominative [subject], genitive [possession], dative [indirect object], accusative [direct object], and ablative [adverbial usages] with 2 numbers: singular and plural. In English, only pronouns have any cases; for nouns and adjectives, we only distinguish number.

For more info, you can download the PDF Assignment

This is one of many solutions. You can use it as your reference, to build your own.

[ more ]

A Binary Tree Assignment: Create a Frequency List of Words in a Passage

PDF assignment

Assignment: Passage will be read from standard input stdin [cin]. The output (to be sent to stdout [cout] will be an alphabetical list of distinct words and number of occurrences of each word.

Note: All characters to be convert to lower case.

This is one of many solutions. There are some unused and unneeded functions added while I was solving this problem. The solution is not optimized and cleaned up, yet it works. I’d like to share it with you, as a reference to build your own solution from this example.

[ more ]