"Dynamic" Object Structures?
From: Randy Yates (yates_at_ieee.org)
Date: 12/29/04
- Next message: sachin_mzn_at_yahoo.com: "map<...>.find"
- Previous message: Chris Theis: "Re: std::vector question"
- Next in thread: Victor Bazarov: "Re: "Dynamic" Object Structures?"
- Reply: Victor Bazarov: "Re: "Dynamic" Object Structures?"
- Reply: Julián Albo: "Re: "Dynamic" Object Structures?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Dec 2004 10:57:11 GMT
Having done a bit of Access Basic programming, I'm realizing
that AB does seem to have (as much as I hate to admit it since
I think it's a toy language) an advantage over C++.
Let's say I have a table called "tblCars" that has the fields fYear
(integer), fModel (string), fMake (string). When I perform a query in
AB, I do something like:
Dim rstCars As Recordset
Dim year As Integer
set rstCars = dbCurrent.OpenRecordset("SELECT * FROM tblCars")
Now here's the rub: I can then access the fields of the recordset
as
year = rstCars!fYear
AB has syntax that allows me to make such a construction at compile-time
that will yield a dynamic result at run-time.
So my basic question is, is there any mechanism in C++ to do a similar
thing?
The closest I can come is to define a recordset object that has a member
function
void * Fields(char* fName);
so that I can say
int year;
recordset rstCars("SELECT * FROM tblCars");
year = rstCars.Fields("fYear");
Is this a reasonable way to do this? Is there any mechanism in C++ to
do it more elegantly?
-- % Randy Yates % "Watching all the days go by... %% Fuquay-Varina, NC % Who are you and who am I?" %%% 919-577-9882 % 'Mission (A World Record)', %%%% <yates@ieee.org> % *A New World Record*, ELO http://home.earthlink.net/~yatescr
- Next message: sachin_mzn_at_yahoo.com: "map<...>.find"
- Previous message: Chris Theis: "Re: std::vector question"
- Next in thread: Victor Bazarov: "Re: "Dynamic" Object Structures?"
- Reply: Victor Bazarov: "Re: "Dynamic" Object Structures?"
- Reply: Julián Albo: "Re: "Dynamic" Object Structures?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]