not inline function warning

This is a discussion on not inline function warning within the C++ Programming forums, part of the General Programming Boards category; im getting this warning: C:\CS240\BinarySearch.h 12: Functions taking class-by-value argument(s) are not expanded inline in function TreeNode::TreeNode(string,TreeNode *,TreeNode *) heres ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    4

    not inline function warning

    im getting this warning:
    C:\CS240\BinarySearch.h 12: Functions taking class-by-value argument(s) are not expanded inline in function TreeNode::TreeNode(string,TreeNode *,TreeNode *)

    heres the class
    Code:
    class TreeNode
    {
    public:
    TreeNode() {}
    TreeNode(string nodeItem, TreeNode *left = NULL, TreeNode *right = NULL):data(nodeItem),leftLink(left), rightLink(right){}
    friend class BST;
    private: 
    string data;
    TreeNode *leftLink, *rightLink;
    };//end TreeNode class
    how do i get rid of that warning and what does it mean?

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    51
    i can't seem to reproduce the warning, but just a guess, try passing nodeItem by reference. It seems to be the only class being passed by value.

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    4
    here are the .h and .cpp files. im stumped, can't get this very annoying warning to go away.

    BinarySearch.h
    Code:
    #include <iostream.h>
    #include <string.h>
    #include <cstddef>
    #include <fstream.h>
    
    class TreeNode
    {
    public:
    	TreeNode() {}
    	TreeNode(const TreeNode& treeNodeObject);
    	TreeNode(string nodeItem,
    			 TreeNode *left = NULL,
    			 TreeNode *right = NULL):
    		data(nodeItem),leftLink(left),
    		rightLink(right){}
    	friend class BST;
    private:	
    	string data;
    	TreeNode *leftLink, *rightLink;
    };//end TreeNode class
    
    class BST
    {
    public:
    	// constructors and deconstructors
    	BST() : root(NULL) {}
    	virtual ~BST();
    	//BST operations
    	void insert(string newItem);
    	bool check(string newItem) const;
    	void retrieve(string key, string& treeItem) const;
    	void inorder() const;
    private:
    	void insert(string newItem, TreeNode *& subTreeRoot);
    	void deleteSubTree(TreeNode *& subTreeRoot);
    	bool check(string newItem, TreeNode *subTreeRoot) const;
    	void inorder(TreeNode *subTreeRoot) const;
    	TreeNode *root;
    }; //end BST class
    BinarySearch.cpp
    Code:
    #include "BinarySearch.h"
    void BST::insert(string item, TreeNode *& subTreeRoot)
    {
    	if (subTreeRoot == NULL)
    		subTreeRoot = new TreeNode (item, NULL, NULL);
    	else if (item < subTreeRoot->data)
    		insert(item, subTreeRoot->leftLink);
    	else
    		insert(item, subTreeRoot->rightLink);
    }
    
    void BST::insert(string item)
    {
    insert (item, root);
    }
    
    bool BST::check(string item, TreeNode *subTreeRoot) const
    {
    	if (subTreeRoot == NULL)
    		return false;
    	else if (subTreeRoot->data == item)
    		return true;
    	else if (item < subTreeRoot->data)
    		return check(item, subTreeRoot->leftLink);
    	else
    		return check(item, subTreeRoot->rightLink);
    }
    
    bool BST::check(string item) const
    {
    	return check(item, root);
    }
    
    void BST::inorder(TreeNode *subTreeRoot) const
    {
    	if (subTreeRoot != NULL)
    	{
    		inorder(subTreeRoot->leftLink);
    		inorder(subTreeRoot->rightLink);
    	}
    }
    
    void BST::inorder() const
    {
    	inorder(root);
    }
    
    void BST::deleteSubTree(TreeNode *& subTreeRoot)
    {
    	if (subTreeRoot != NULL)
    	{
    		deleteSubTree(subTreeRoot->leftLink);
    		deleteSubTree(subTreeRoot->rightLink);
    		delete subTreeRoot;
    		subTreeRoot = NULL;
    	}
    }
    
    BST::~BST()
    {
    deleteSubTree(root);
    }
    //void BST::deleteItem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21