473,382 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to specify dynamic object names ?

Have to create a linked list of objects of the same type based on user
input. The number of objects in the list is dynamic depending on the
number input from the user. What would be the best way to name these
objects ?

Thanks,
vivekian

Nov 29 '05 #1
5 1925
>> What would be the best way to name these objects
you will be accessing the linked list with a single pointer pointing to
the start of the list. You don't require to store names for each
object.
If you save each object name and use it what is the need for linked
list then.

Nov 29 '05 #2

/Gogineni/ wrote:
What would be the best way to name these objects

you will be accessing the linked list with a single pointer pointing to
the start of the list. You don't require to store names for each
object.
If you save each object name and use it what is the need for linked
list then.


Depending on the behavior the OP is looking for (queue vs. stack) they
might want a second ptr at the tail. I'm sure you know this - more for
the OP.

Nov 29 '05 #3

"vivekian" <vi********@gmail.com> wrote in message
news:11********************@f14g2000cwb.googlegrou ps.com...
Have to create a linked list of objects of the same type based on user
input. The number of objects in the list is dynamic depending on the
number input from the user. What would be the best way to name these
objects ?


What do you mean by "name these objects"? Given the following:

struct AClass
{
std::string myName;
AClass( const char* theName ) : myName( theName ) {}
};

AClass specificClass;

What is the "name" you're referring to? Is it the class name "AClass", the
member "myName", or the variable name "specificClass"?

Given an answer to that, what does it have to do with the user specifying
the number of objects, as your question stated? Where does dynamically
naming the objects come into play?

-Howard
Nov 29 '05 #4
Howard wrote:
What do you mean by "name these objects"? Given the following: struct AClass
{
std::string myName;
AClass( const char* theName ) : myName( theName ) {} }; AClass specificClass;


I refer to the variable name specificClass. That is the naming of the
objects of the type AClass. The user input will be the number of AClass
objects to be created. This number is accepted at runtime.

I am not sure , but maybe i dont need to name these objects at all.
Would something like

AClass * temp ;
temp = new AClass () ;

do the trick . Then i can just link temp in the linked list as a node
and keep creating for the number of objects specified. Hope i am clear.
Maybe am thinking along the wrong lines.

vivekian

Nov 29 '05 #5

"vivekian" <vi********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Howard wrote:
What do you mean by "name these objects"? Given the following:
struct AClass
{
std::string myName;
AClass( const char* theName ) : myName( theName ) {}

};

AClass specificClass;


I refer to the variable name specificClass. That is the naming of the
objects of the type AClass. The user input will be the number of AClass
objects to be created. This number is accepted at runtime.

I am not sure , but maybe i dont need to name these objects at all.


Probably not.
Would something like

AClass * temp ;
temp = new AClass () ;

do the trick . Then i can just link temp in the linked list as a node
and keep creating for the number of objects specified. Hope i am clear.
That would work fine (but you can combine it into one line inside your
loop). If a linked list of your own making is not required (i.e., for
homework), then you should consider using std::list (or whatever container
is appropriate) to hold the pointers. And, if you have the Boost libraries,
you could use their smart pointer class instead of using raw pointers like
your example.
Maybe am thinking along the wrong lines.

vivekian

Nov 29 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon | last post by:
Am using the following code. <script language="JavaScript1.2"> function setquantity(productindex,productquantity) { //create the reference object irefname_none = eval("document." +...
9
by: firegun9 | last post by:
Hello all, After looking for the solution for a while in the group, I know this is not possible in C++. So I just say my problme here. The input file is: dev1 1 1 dev2 0 0 0 6 There is a...
5
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
1
by: Brent | last post by:
I can't seem to locate any easy way to create dynamic class properties. Essentially, I want to take the column headers from a data result set, create a property having the column header name, and...
5
by: Sakcee | last post by:
python provides a great way of dynamically creating fuctions calls and class names from string a function/class name can be stored as string and called/initilzed e.g def foo(a,b): return...
22
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I...
3
by: Mark S. | last post by:
As I understand it, C# doesn't offer dynamic variable names. Below is my attempted workaround. Is what I'm doing possible? FYI, I already read all the "why in the world do you need dynamic...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.