473,387 Members | 1,572 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,387 software developers and data experts.

Creating an object in C++

41
Does anyone know how i could create an object1 (init) and pass it in to another object to do some analysis in c++
where by object1 initailises 4 differnt structures


at start up time the init object1 is initilised by passing in the appropriate values to each structure below.

The following structures will have the following types

structure 1 - startDateTime : unix timestamp.
endDateTime : unix timestamp


structure 2 - startDate : unix timestamp.
endDate : unix timestamp.
bandStartTime : offset from 00:00:00 in seconds.
bandEndTime : offset from 00:00:00 in seconds.


structure 3 - startDay : a string (Mon, Tue, Wed, etc).
endDay : a string (Mon, Tue, Wed, etc).
startTime : offset from 00:00:00 in seconds.
endTime : offset from 00:00:00 in seconds.


structure 4 - startDay : a string (Mon, Tue, Wed, etc).
endDay : a string (Mon, Tue, Wed, etc).
startTime : offset from 00:00:00 in seconds.
endTime : offset from 00:00:00 in seconds.
Mar 22 '07 #1
8 1559
sicarie
4,677 Expert Mod 4TB
Does anyone know how i could create an object1 (init) and pass it in to another object to do some analysis in c++
where by object1 initailises 4 differnt structures


at start up time the init object1 is initilised by passing in the appropriate values to each structure below.

The following structures will have the following types

structure 1 - startDateTime : unix timestamp.
endDateTime : unix timestamp


structure 2 - startDate : unix timestamp.
endDate : unix timestamp.
bandStartTime : offset from 00:00:00 in seconds.
bandEndTime : offset from 00:00:00 in seconds.


structure 3 - startDay : a string (Mon, Tue, Wed, etc).
endDay : a string (Mon, Tue, Wed, etc).
startTime : offset from 00:00:00 in seconds.
endTime : offset from 00:00:00 in seconds.


structure 4 - startDay : a string (Mon, Tue, Wed, etc).
endDay : a string (Mon, Tue, Wed, etc).
startTime : offset from 00:00:00 in seconds.
endTime : offset from 00:00:00 in seconds.
Create the object, and then pass it to the next.

What have you tried on this?
Mar 22 '07 #2
nano2
41
Create the object, and then pass it to the next.

What have you tried on this?
What do you mean with the above ?
Mar 22 '07 #3
sicarie
4,677 Expert Mod 4TB
[quote=nano2]

What have you tried on this?[/QUOTO]

What do you mean with the above ?
I mean what have you done to try to solve the problem yourself.

Our FAQ:

Posting Homework or Coursework Questions and Answers
This site is not a place where you can get your homework and course work done for you. Ignoring the questionable morals of getting someone else to do your work towards a formal qualification you will learn a lot more by attempting the problem yourself, then asking for help with the bits that are not working. You will be more likely to get help if you appear to have made an attempt at the problem yourself.
If it appears that the question has just been pasted directly from a text book or coursework assignment our moderators have been instructed to meet this with a set response. This is a pre-written message asking you to make some attempt at the assignment yourself before asking questions about specific problems and referring you to this FAQ.
Do NOT post your complete source code. Remember, you found this site, so can your professors and tutors and they are likely to take a dim view if you hand in something that appears to be copied from this site. In most academic institutes the minimum response to copying of assignments is a 0 mark for the assignment in question. If you post your entire code your professor will not know it was your work, you may be penalised for copying from yourself.
If an expert requests that you provide more of your code then you can PM it to them, however please do not PM them your code unless requested.
Acceptable questions that students can ask are on functionality and theory or syntax corrections in small posted code snippets.
Please make sure you have asked an actual question worded in English outside of the text of your assignment that you have posted.
Mar 22 '07 #4
nano2
41
[quote=sicarie]

I mean what have you done to try to solve the problem yourself.

Our FAQ:
Oh sorry yes i have written it in C. it's not home work it's just another approach i am taken to it so that i can have more effecient api.
Mar 22 '07 #5
sicarie
4,677 Expert Mod 4TB
[quote=nano2]
Oh sorry yes i have written it in C. it's not home work it's just another approach i am taken to it so that i can have more effecient api.
Ok, so what have you tried?
Mar 22 '07 #6
nano2
41
[quote=sicarie]

Ok, so what have you tried?
for structure 1 building it up

This is the pseudo code :

method_createDateTime {startDateTime endDateTime } {
struct datetimeStruct

assign datetimeStruct("type") = "0"
assign datetimeStruct("startDateTime") =startDateTime
assign datetimeStruct("endDateTime") = endDateTime
return $datetimeStruct
}
Mar 22 '07 #7
sicarie
4,677 Expert Mod 4TB
object1 is initilised by passing in the appropriate values to each structure below.
Ok, you're getting the right idea, but not entirely, and not with the correct implementation. You don't need to create a new struct - there are 4 you are going to create with your initalization. You need to figure out how to create that oject, which will in turn create those structs, and then set the values in them. You ahve the right idea to create structs and intialize them, but you first need to create this object1.

If you just create this object (with no parameters - don't worry about it creating the structs yet), that's the first step. Once you get that completed, you can either use the constructor, or create methods to create those 4 structs (I would recommend both, along with a default constructor). Once you get it to create them (not set them at all, just create them), then you can worry about passing them variables.

Does that make sense?
Mar 22 '07 #8
nano2
41
Ok, you're getting the right idea, but not entirely, and not with the correct implementation. You don't need to create a new struct - there are 4 you are going to create with your initalization. You need to figure out how to create that oject, which will in turn create those structs, and then set the values in them. You ahve the right idea to create structs and intialize them, but you first need to create this object1.

If you just create this object (with no parameters - don't worry about it creating the structs yet), that's the first step. Once you get that completed, you can either use the constructor, or create methods to create those 4 structs (I would recommend both, along with a default constructor). Once you get it to create them (not set them at all, just create them), then you can worry about passing them variables.

Does that make sense?

Can you have a look at this implementation please as I feel there is a better approach to this implementation:

thanks

class classificationSet
{
public:
ClassifictaionSet( int startDateTime = 4712548, int endDateTime=124556, char * classBandType = NULL)
: m_classBandSet(NULL)

{
}
~classificationSet()
{
delete m_classBandSet;
}

value_t * getClassBandSets() { return m_classBandSet; }

}

CreateClass(){

classificationSet *ptr = 0;

ptr * = new ClassificationSet();

char *classBandSettype = ptr->getclassBandSets();

}

What i am trying to do here is build up a classification structure where the user will call the object like so


Createprog 24214155, 154151555435, "type0"

// I need to extend the class to hold startday, endday starttime endtime values
Createprog Monday Sunday 0 86400 "type1"

Createprog Monday Friday 28800 64801 "type3"
Mar 27 '07 #9

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

Similar topics

8
by: mcmg | last post by:
Hi, I have an asp app that works fine on a windows xp machine but does not work on a windows 2000 server. I have the following code in my global.asa: <OBJECT RUNAT=Server SCOPE=SESSION...
6
by: Davinci_Jeremie | last post by:
Hi Newbee here to C# I have a simple questions... In a Hello world example how does the class object Hello exist with out creating it? I come from object pascal where everything object is...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
17
by: Lee Harr | last post by:
I understand how to create a property like this: class RC(object): def _set_pwm(self, v): self._pwm01 = v % 256 def _get_pwm(self): return self._pwm01 pwm01 = property(_get_pwm, _set_pwm)
6
by: wcc | last post by:
Hello, How do I create a class using a variable as the class name? For example, in the code below, I'd like replace the line class TestClass(object): with something like class...
2
by: Moses | last post by:
Hi All, Is is possible to catch the error of an undefined element while creating an object for it. Consider we are not having an element with id indicator but we are trying to make the object...
11
by: Matthew Wells | last post by:
Hello. I have figured out how to create an instance of an object only knowing the type by string. string sName = "MyClassName"; Type t = Type.GetType(sName); Object objNew =...
9
by: =?Utf-8?B?YmJn?= | last post by:
Hi all, I read somewhere "using kernel stuff in thread is not good.." if ManualResetEvent object is created in thread but not actually used, will it affect performance? Bob
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.