473,320 Members | 2,071 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,320 software developers and data experts.

How to create objects dynamically

I have created a class CMyGraph, which plots points of a graph on screen. The code i am using right now is as follows.

CMyGraph* plotPoint1 = new CMyGraph();
plotPoint1->SetData(0, 64);
But if i have to plot multiple points i do it hardcoded like.. ..
CMyGraph* plotPoint1 = new CMyGraph();
plotPoint1->SetData(0, 64);
CMyGraph* plotPoint2 = new CMyGraph();
plotPoint2->SetData(0, 64);
CMyGraph* plotPoint3 = new CMyGraph();
plotPoint3->SetData(0, 64);
I intent to do this dynamically , i.e. the values will come from the database. And those many points will be plotted. In short those many objects will be created. I am a newbie .. can anyone suggest a solution for that
Aug 10 '06 #1
2 2875
malik
4
You can create an array of objects that is pointed by a pointer like...

CMyGraph* ptr = new CMyGraph[num];
//where num = the number of objects you want to create at run time.

then is a for loop take the points from the user at run time using the setdata function..
Aug 10 '06 #2
Banfa
9,065 Expert Mod 8TB
Can't your write your CMyGraph class so that it can plot multiple points?

But if i have to plot multiple points i do it hardcoded like.. ..

CMyGraph* plotPoint1 = new CMyGraph();
plotPoint1->SetData(0, 64);
plotPoint1->SetData(0, 64);
plotPoint1->SetData(0, 64);
Aug 10 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: sirsean | last post by:
Hi all. I'm trying to dynamically build menus and objects after my page loads. Data is stored in an XML file and is parsed at runtime into Javascript objects. At the moment, I'm working on creating...
2
by: Sean | last post by:
Hello all, I may just not be searching for the right thing, but I've been looking for a way to dynamically create controls (and name them) in my code so that I can create only the controls I...
4
by: Ray | last post by:
I want to dynamically load DLLs (created from VB) and instantiate a class with a particular name, like "ProcessClass". I am able to load the DLL and confirm there is a class by that name BUT I...
4
by: vertigo | last post by:
Hello I need to create some objects durring program execution - but it's names are dynamically generated (depends on parameters). How can i do it ? Thanx Michal
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
2
by: nanabuch | last post by:
Hello, I posted yesterday a very complex question, but I did not receive a adequate answer so I decided to simplify things, and I will try to figure out the rest of the problem :). Ok, I need...
18
by: Angus | last post by:
Hello We have a lot of C++ code. And we need to now create a library which can be used from C and C++. Given that we have a lot of C++ code using classes how can we 'hide' the fact that it is...
11
by: =?Utf-8?B?UGV0ZXIgSw==?= | last post by:
I am working with Visual Studio or alternately with Expression Web. I need to create about 50 aspx pages with about 1200 thumbnali images, typically arranged in three to four groups per page,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.