Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:01:48+00:00 2026-06-05T16:01:48+00:00

I have a Binary Search Tree, I use template to add any class object

  • 0

I have a Binary Search Tree, I use template to add any class object to it.

I have a search function that returns said class object or NULL

Do I need to overload “=” to return this object ? I was hoping if I return object it would know to check: If same type replace values stored in LHS with values stored in RHS and if NULL mark first object as NULL.

Is my mistake maybe somewhere else (all I return is either full object or NULL, nothing else) or do I actually have to overload it ?

I have limited time (very) so how can I do this if needed ? and is it a fast process or will it involve a lot of modifications.

Sorry for lack of code but I can’t think of any that would be relevant.

EDIT I also use a lot of NULL so can I return NULL into an object ? Example:

class Matrix {
   private:
     int col;
     int line;
     int value;
}

Matrix mat; mat = NULL;

Some code:

template <typename Type>
Type BST<Type>::search(int key) {
    if (this->root == NULL)
        return NULL;
    else
        return root->search(key);

Here Type is Matrix. Can I return NULL or go further with search and return Type, which again is Matrix?

Note: This is for homework purposes, leaking memory is my last concern. Simplicity and speed is by far my first problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:01:50+00:00Added an answer on June 5, 2026 at 4:01 pm

    No, you cannot assign NULL to an object.

    Matrix mat; mat = NULL;
    

    Is illegal in your case. If you want to be able to have NULL, you can use pointers instead (raw or smart).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that builds a binary search tree over a rather
I have a binary search function that will search for a word in an
In binary search tree we have the node strucure as class Node { public:
Since black red tree is a binary search tree I have decided to use
So recently I have been working on phonebook project that uses Binary Search Tree.
I have a Binary Search Tree that I'm making and I implemented the Insert
I have a Binary Search Tree as a derived class from a Binary Tree,
Have written a Binary Search Tree that stores data on ships, the key for
1-)For sorted array I have used Binary Search. We know that the worst case
I have a modified version of binary search that takes in an array in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.