Click here to Skip to main content
15,881,744 members
Articles / Desktop Programming / MFC

Tree Container Library

Rate me:
Please Sign up or sign in to vote.
4.85/5 (29 votes)
22 Aug 2007Zlib10 min read 228K   7.2K   111  
A generic template class library for storing data in a tree-like structure.
#pragma once
#include <string>

class Alpha
{
public:
	Alpha() { text = ""; }
	Alpha(const std::string& _text);
	Alpha(const char* _text) { text = _text; }
	~Alpha();

	friend bool operator < (const Alpha& lhs, const Alpha& rhs) { return lhs.text < rhs.text; }
	friend bool operator ==(const Alpha& lhs, const Alpha& rhs) { return lhs.text == rhs.text; }

	std::string get_text() const { return text; }
	void set_text(const std::string& _text) { text = _text; }
	void set_ranking(int _ranking) { ranking = _ranking; }  // non-const operation
	int get_ranking() const { return ranking; }


private:
	std::string text;
	int ranking;
};


class Beta 
{
public:
	Beta() { text = ""; }
	Beta(const std::string& _text) : text(text) {}
	~Beta() {}

	std::string get_text() const { return text; }
	void set_ranking(int _ranking) { ranking = _ranking; }  // non-const operation
	int get_ranking() const { return ranking; }


private:
	std::string text;
	int ranking;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License



Comments and Discussions