Solved

Pointers

Posted on 1998-10-06
3
188 Views
Last Modified: 2010-04-01
variable type a;

What should be the variable type(say,int/char/char* etc.)so that,
a = &a =*a = same output/result?.
That is,what should be then the variablke type of a.
0
Comment
Question by:tmmet
  • 2
3 Comments
 
LVL 1

Expert Comment

by:Booth882
ID: 1174604
is this a riddle?
0
 
LVL 1

Accepted Solution

by:
Booth882 earned 0 total points
ID: 1174605
there is no general type that would accomplish this.

but if you have an int that contains a hexidecimal value equal to its address this would be true.

    int AnInteger;

    AnInteger = &AnInteger;

if you did this then your statement

    AnInteger  ==  &AnInteger  ==  *AnInteger.

would be true.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1174606
a(){
    printf("%d %d %d\n",a==*a,a==&a,&a==*a);
}

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now