Printing class address!


 
Thread Tools Search this Thread
Top Forums Programming Printing class address!
# 1  
Old 03-01-2011
Printing class address!

Hello everyone,

I have this code which prints the address of the object of a class....bt. what if I want to print the address of the class?

Code:
#include <iostream.h>

class har{
};

int main()
{
har a;
cout<<(&a);
}

I would really appreciate if someone can help!

Thanks!!!!!
# 2  
Old 03-01-2011
Code:
#include <stdio.h>

printf("%p", &object);

should work. If you insist on a C++ solution, you could do:
Code:
#include <stddef.h>

...

cout << (ptrdiff_t)&obj;

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

2. Programming

Printing values from a class

I have a class and want to print values in MOD using L = new Layer* ; How can I print the values in MOD using this object L??? class Layer { public : Model* MODP; Model* MODS; (1 Reply)
Discussion started by: kristinu
1 Replies

3. Shell Programming and Scripting

Finding if my IP address belongs in a Class C group

I need help with a tcl code. I have a variable "myIP" which reads IP address from socket. How do I use regex to find out if it belongs to a group for e.g., 50.65.75.240/28 or 50.65.75.128/25 etc. (2 Replies)
Discussion started by: ampak
2 Replies

4. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

5. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

6. UNIX for Dummies Questions & Answers

Printing pointer address

How can I print the memory address of a pointer using printf (or any other STDOUT functions?). I see in Linux its %p but not in unix, help? thanks (5 Replies)
Discussion started by: perleo
5 Replies

7. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

8. UNIX for Dummies Questions & Answers

car class (not school class)

im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
Discussion started by: rickym2626
1 Replies

9. UNIX for Dummies Questions & Answers

can unix printing directly to ip address

Thanks in advance. I am researching if it is possible for unix (solaris) to print directly printers with IP addresses. Without adding all the ip addresses to the hosts file? There are more than a hundred printers and managing them in a hosts file would be tedius, prone to error, and time... (4 Replies)
Discussion started by: maguired
4 Replies
Login or Register to Ask a Question