?
Solved

What is reflection in C++?

Posted on 2003-03-02
7
Medium Priority
?
275 Views
Last Modified: 2010-04-01
I am trying to find out about reflection in C++. I've so far not been able to locate the right definition of term or the application of it in C++. Can someone give a brief explanation about it.

Thanks a lot.

0
Comment
Question by:rdukb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 8053310
I'm unfamiliar with the term "reflection" in the context of C++ programming.  Please elaborate.
0
 
LVL 8

Accepted Solution

by:
mnashadka earned 300 total points
ID: 8053322
Run-time type information (RTTI) is similar to the concept of reflection in Java and a couple of other languages.  It's the idea where the class knows a couple of things about itself (such as its name).  Look up typeid.
0
 

Author Comment

by:rdukb
ID: 8053415
To be honest I do not know the context. I was asked this question recently in an Interview and I was curious to find out the correct answer.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:shepnorfleet
ID: 8053697
maybe he was referring to reflection-X, a lot of companies have windows workstations that talk to unix development servers.

Just a thought.
0
 
LVL 6

Expert Comment

by:gj62
ID: 8053752
It is a trick (or poorly phrased) question:

Reflection is common in Java:

Reflection enables Java code to discover information about the fields, methods and constructors of loaded classes, and to use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions. The API accommodates applications that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class.

As mnashadka said, RTTI is a first step in that direction, but really is not a complete enough to be termed reflection.

For a more in-depth discussion, try:

http://www.garret.ru/~knizhnik/cppreflection/docs/reflect.html
0
 

Author Comment

by:rdukb
ID: 8054121
Thanks. I found that indeed this is the case. gj62, thanks I saw the article.
0
 
LVL 1

Expert Comment

by:simpsons17371
ID: 8054174
what is the point of a reflection
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

777 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