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 9280537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:53:43+00:00 2026-06-18T17:53:43+00:00

i am new to c++ programming, can we declare some members of class as

  • 0

i am new to c++ programming, can we declare some members of class as friend to other class. it means Lets say Class A have three member functions and instead of declaring whole class as friend to other Class B (say) can i declare only one member of class A as friend to Class B, so please help.

  • 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-18T17:53:44+00:00Added an answer on June 18, 2026 at 5:53 pm

    Yes you can declare a single member function as friend of another class.
    Online Sample:

    #include<iostream>
    class Myclass;
    class Otherclass
    {
        public:
          void doSomething(Myclass &obj);
    
    };
    class Myclass
    {
        int i;
        friend void Otherclass::doSomething(Myclass &obj);
    };
    void Otherclass::doSomething(Myclass &obj)
    {
        obj.i = 10;
        std::cout<<obj.i;
    }
    
    
    int main()
    {
        Myclass obj;
        Otherclass obj2;
        obj2.doSomething(obj);
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I want to create a new programming language or use some language
I am new to python programming..can someone suggest some way to do the following:
Im new to programming and hopefully can get some guidance, I searched for clues
I am very new to programming and I can't seem to find a way
Fairly new to programming. I just can't wrap my head around how to get
I am fairly new to Android programming and was wondering how I can get
I'm new to C programming. I want to create C program which can read
I'm new to the world of Mac programming. Can someone please tell me what
I'm pretty new to asp net 2.0 programming and I was wondering how can
let's say that you in your new programming work your boss comes and says

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.