Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2005, 10:20 AM
Registered User
 
Join Date: Apr 2005
Location: waterloo, IA, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamic class/object access

We use VB and VB scriptcontrol way to much where I work.
Some of the core processing happens with scripts for the scriptcontrol.
Needless to say it makes for some slow processing.
I am working to create a compatible interpreter for these scripts.
I am using java at the moment , but I want to port it to c++ down the road. Linux c++ specifically.
I am using the "Reflections" class in java, to allow script access to other objects in the program, without having to code the access for each specific class.
VBscript control uses the AddObject method to provide access to class objects to the script.
I would like to find out what I can use in c++ that could help in providing this functionality.

Lets say I had a class called Box that had width, length and height properties or methods. In my script I could write "Box.width = 2" my interpreter would be able to reference the Box.width method and set the value to 2.

Hope this is clear enough.....if not let me know, so I can attempt to do a better job of explaining.

Reply With Quote
  #2 (permalink)  
Old April 10th, 2005, 02:02 AM
Authorized User
 
Join Date: Mar 2005
Location: Wagga Wagga, NSW, Australia.
Posts: 60
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Alan-LB Send a message via Yahoo to Alan-LB
Default


class Box // Class of Box - this is a description not an Instance
{
  public: // Any client can access Public Methods
    void SetWidth(int Input); // Declaration of Method to set width
  private: // Members are only available through Methods
    int Width, Length, Height; // Class Members (Properties)
}

void Box::SetWidth(int Input) // Definition of Method to set width
{
  Width = Input;
}

Box MyBox; // Object (Instance) MyBox of Class Box

MyBox.SetWidth(2); // This will set the Width for the Object MyBox to 2

--------------------------------------------------------------------

In C++ Properties are known as "Member Variables" or "Data Members"

Does this help??

Alan.


Reply With Quote
  #3 (permalink)  
Old April 16th, 2005, 03:07 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default


 hmmm I think he's trying to do that without access to the source code, judging by his reference to the Reflection API and the fact that he's writing an interperter, such that if I produced an object named TestObject with a method SomeFunc() and gave him only the bytecode, he would be able to make his interperter execute TestObject.SomeFunc().
 There's no simple way to examine the structure of a C++ class that I'm aware of at runtime, similiar to the Reflection API in java. It's possible, but non-trivial .. you would need to implement code to examine, for example, the VFUNCTION table and such. That is, you would essentially have to write your own analog to the Reflection API.
 You might want to look at the source code for some open source debuggers (e.g. GDB) .. perhaps that would get you started on your way.

Regards
Meredith Shaebanyan

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic compilation of class based on xsd vhrao .NET Framework 3.5 0 July 7th, 2008 03:53 PM
access class object Sheraz Khan ASP.NET 2.0 Professional 0 September 10th, 2007 06:19 PM
Property access from Class within Partial Class zoltac007 C# 2005 0 December 1st, 2006 01:01 AM
SQL in C# class vs. Dynamic Stored Procedure holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 October 26th, 2006 06:45 PM
How to create a class instance dynamic??? ffbalota C# 0 September 21st, 2003 04:49 PM



All times are GMT -4. The time now is 09:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.