By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,232 Members | 1,719 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,232 IT Pros & Developers. It's quick & easy.

Creating an object in C++

P: 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
Share this Question
Share on Google+
8 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
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

P: 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
Expert Mod 2.5K+
P: 4,677
[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

P: 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
Expert Mod 2.5K+
P: 4,677
[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

P: 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
Expert Mod 2.5K+
P: 4,677
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

P: 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

Post your reply

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