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

  • Home
  • SEARCH
  • 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 1025623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:57:20+00:00 2026-05-16T11:57:20+00:00

//node.h class node { public: void sort(node n); }; I didn’t try the code

  • 0
//node.h 
class node 
{
      public:
            void sort(node n);

};

I didn’t try the code yet . But It’s interesting to know if is this a valid case and Why ?

Edit :

This leads me to another question :
Can I declare FOO inside a member function like this ?

//FOO.h
Class FOO
{
   public:
   void sort(int n) ;
   void swap(int x , int y ); 
}

//FOO.cpp

void FOO::sort (int n)
{
     FOO obj;
     obj.swap(3 , 5) ;
}
  • 1 1 Answer
  • 1 View
  • 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-05-16T11:57:21+00:00Added an answer on May 16, 2026 at 11:57 am

    Having now established that your question is solely related to passing node by value in a member (rather than passing node* or node&) the answer is still yes. You can even define the body of the member within the class is you so wish.

    As to why, think of things from the compiler’s point of view. As it parses the class all it really needs to know are what data members there are within it and what the function member signatures are. None of the function member definitions need to be parsed at this point so the compiler would not be alarmed at the prospect of seeing an actual node as an argument. Only when it’s finished parsing the data and signatures would it go back and actually deal with the function member definitions and at that point it knows precisely what a node is.

    In answer to your second question you can define instances of your class within the member (for the same reason).

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

Sidebar

Related Questions

I have a recursive model like this: public class Node { public int Id
I have this class: public class Source extends Node { protected DistributionSampler delay ;
I have this very simple C++ class: class Tree { public: Node *head; };
i have this two method public static void NavigateAndExecute(Node root, Action<Node> actionToExecute) { if
public class Node { private Node nextNode; @Override public int hashCode() { //How to
I have a class: class node { public: node& parent; } I want to
I have a class like the following: class node { public: node* parent; std::list<node*>
I have a Java class, Node as follows : class Node { public ArrayList<Node>
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {
I tried adding a custom method to the Node class but ended up creating

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.