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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:32:43+00:00 2026-05-30T04:32:43+00:00

the question is how to get pointer to self inside method of a class

  • 0

the question is how to get pointer to self inside method of a class without touching this:

class Foo
{
   int a, b, c;
   void Print();
};

This way in common compiler I can do this refering to first data field:

void Foo::Print()
{
   cout << &a; // == this
}

But are there any ways to do this without data members when only function exists?

class Foo2
{
   void Print();
};

p.s. don’t even ask me why do I need this 🙂

  • 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-05-30T04:32:44+00:00Added an answer on May 30, 2026 at 4:32 am

    For a POD class with at least one data member, the address of the class-type object is the same as the address of its first data member. This is because there can be no unnamed padding bytes before the first data member of a POD struct type. [In C++11, the rules are a bit different; I believe that this is true for all standard layout class types. I am not entirely familiar with the rules, however.]

    For any other class type, there is no way to do this.

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

Sidebar

Related Questions

So this question will get technical – eventually – but first check out Hanselminutes
Hopefully the last NN question you'll get from me this weekend, but here goes
Without the following: ATL MFC Question: How to get the COM Server , to
This is a bit of a lazyweb question but you get the rep so
The reason for me asking this question is:- I get a real buzz out
Quick question. Does anyone know how to get the function pointer of an objective
Related to my other question How can I get the address (acctual function pointer)
This question is based on a previous question: How does C# compilation get around
Quick question: How do I get a pointer to a pre-declared function in javascript.
This is purely a theoretical question, I know that if someone declares a method

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.