Go Back   Naruto & Bleach Mania Forums > General Discussion > General Discussion & News
User CP Rules & Info Arcade Gallery

http://www.narutomania.com/forums/New Month, New Problems
For these forums to remain up we need $480 within 7 days. Please donate HERE We need this amount no matter what to keep this website up. Thank you for your support.

Reply
 
Thread Tools
Old 15-02-2008, 02:14 PM   #1081
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default

Yes, arguments always must have types.
MuKen is offline   Reply With Quote
Old 19-02-2008, 05:13 AM   #1082
Chuunin
 
marti810's Avatar


Join Date: Apr 2007
Posts: 334
My Mood:
Rep Power: 0
marti810 is an unknown quantity at this point
Default Re: Homework Help v1.3

im in a photography class and im shooting some metallic objects. the glare on them is really bad anyone know a way to get rid of that without losing proper lighting.
marti810 is offline   Reply With Quote
Old 20-02-2008, 04:39 AM   #1083
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

Write an array-based implementation for the ADT sorted list,


· Use a class for the implementation.

· Use a typedef to make it easy to change the kind of items stored in the list.

· Do not use any STL data structure facilities in your implementation. In particular, use arrays, not vectors.

· Note that the ADT has positions 1, 2, 3, etc. while a C++ array has indices 0, 1, 2, etc. The user of your class acts as if he or she is working with the ADT and must be able to treat position 1 as the first position, regardless of the details of your implementation. Do use indices starting from 0, but hide this implementation detail from the user.

· Make sure sample runs illustrate all of the functionality of your class. As always, output should be commented to indicate what’s being tested in each part of each run.

· Ideally, your implementation should allow the list to store any number of items, but you’re likely to find this hard. Work first toward a version that allows up to a fixed maximum number of items. If you have time after that’s operational, see if you can figure out how to get the size of the array to expand as necessary so that there’s no limit to the number of items that can be stored.
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 26-02-2008, 02:30 AM   #1084
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

two questions,

What's typedef,
and

Since I'm using a class, vectors would have been easy for me. Since I can just make a private data member a vector. But I have to use an array. I'm not sure what to do here, how can I combine an array with a class? I think that's the question I'm asking.
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 26-02-2008, 04:51 AM   #1085
Genin


Join Date: Oct 2005
Posts: 75
Rep Power: 0
ahme has much to be proud ofahme has much to be proud ofahme has much to be proud of

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

Quote:
Originally Posted by Ice(v)an View Post
two questions,

What's typedef,
and

Since I'm using a class, vectors would have been easy for me. Since I can just make a private data member a vector. But I have to use an array. I'm not sure what to do here, how can I combine an array with a class? I think that's the question I'm asking.
typedef is a keyword originally used in C to give a data type another name.
Take this example:

#include <iostream>
using std::cout;
int main(){
typedef int Grade; // letting Grade acts as an integer to have more descriptive name
Grade exam1=100;
Grade exam2=80;
cout << "Your grade for exam1: " << exam1;
cout << "\nYour grade for exam2: " << exam2;

return 0;
}

This simple program will output:
Your grade for exam1: 100
Your grade for exam2: 80

You can check wikipedia for more details: typedef - Wikipedia, the free encyclopedia

Last edited by ahme; 26-02-2008 at 04:54 AM.
ahme is offline   Reply With Quote
Old 26-02-2008, 04:58 AM   #1086
P
Chuunin
 
P's Avatar


Join Date: Sep 2004
Posts: 226
My Mood:
Rep Power: 18
P is just really nice
Send a message via MSN to P
Default Re: Homework Help v1.3

Give an example of a function f that is continuous on R but for which f(R) is bounded, open interval.

R = set of all reals
__________________

P is online now   Reply With Quote
Old 26-02-2008, 09:28 PM   #1087
Administrator
 
o({})o's Avatar


Join Date: Sep 2004
Location: Yuritopia!
Posts: 2,895
My Mood:
Rep Power: 666
o({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond reputeo({})o has a reputation beyond repute

Basic Bronze Basic Bronze Basic Gold Intermediate Silver Award Basic Gold 
Total Awards: 5

Send a message via ICQ to o({})o Send a message via Yahoo to o({})o
Default Re: Homework Help v1.3

f(x) = -ex for all x in R.

lim[x->-infinity]( f(x) ) = lim[x->-infinity]( -ex ) = lim[x->infinity]( -1 / ex ) = 0
lim[x->infinity]( f(x) ) = lim[x->infinity]( -ex ) = -infinity

f(x) is continuous on R and is bounded because 0 > f(x) for all x in R. Also, f(x) lies on the open interval (-infinity, 0).
__________________
Yuri FTW! - Created by: gooserapids
o({})o is offline   Reply With Quote
Old 26-02-2008, 09:36 PM   #1088
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

I'm not sure if this is correct.

Let say I have a class,

can I say in the private

private:
int x[20];

Where we have a class that has an array of x, with 20 max, as it's private data member?
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 26-02-2008, 11:40 PM   #1089
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

Quote:
Originally Posted by Ice(v)an View Post
I'm not sure if this is correct.

Let say I have a class,

can I say in the private

private:
int x[20];

Where we have a class that has an array of x, with 20 max, as it's private data member?
Yes, that is valid.

The reason they asked you to use typedef is so that you can easily change what your array stores. So at the top of you file you should have something like

Code:
typedef int MyType;

Then declare your array like

Code:
MyType contents[];
To make an array of MyTypes.

Then, you can easily change the typedef to something like

Code:
typedef float MyType;
So that your code stores floats instead of ints.
MuKen is offline   Reply With Quote
Old 27-02-2008, 03:02 AM   #1090
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

I'm still not sure why we need typedef.

because it's the same as int a[20], a is an array of ints right?
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 27-02-2008, 04:23 AM   #1091
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

Quote:
Originally Posted by Ice(v)an View Post
I'm still not sure why we need typedef.

because it's the same as int a[20], a is an array of ints right?

Well, your class might have something like

Code:
private:
  int a[20];
  int numElements;

public:

int elementAt(int index) {
  return a[index - 1];
}

void addElement(int element) {
  a[numElements] = element;
  numElements++;
}
And so on and so forth. Now if suddenly you decide you want your class to store float instead of int, you have to change all those ints to floats. If instead, you used typedef:


Code:
typedef int ArrayType;

private:
  ArrayType a[20];
  int numElements;

public:

ArrayType elementAt(int index) {
  return a[index - 1];
}

void addElement(ArrayType element) {
  a[numElements] = element;
  numElements++;
}
You can change from into to float just by changing that one line at the top. That's why your teacher wants you to use typedef.
MuKen is offline   Reply With Quote
Old 27-02-2008, 04:33 AM   #1092
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

I get that...I still don't know why we have to use it. It's not really doing anything efficient...it's just time-saving I guess...but this is just schoolwork.
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 27-02-2008, 04:39 AM   #1093
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

Haha, well yes in terms of what is generated by the compiler it literally makes no difference, the compiler's going to replace the typedefs anyway.

However, if you do end up coding for a living, appropriate use of typedefs will be required. Code that is easy to maintain and adapt has a very real monetary value.
MuKen is offline   Reply With Quote
Old 28-02-2008, 02:04 PM   #1094
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

So in my class.

typedef int myArray

class

private:

myArray = anArray[20]

Now should I create a random number code, that will then be stored into the Array, or do I put a code in the main, asking the user to input 20 numbers?
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 28-02-2008, 04:37 PM   #1095
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

Quote:
Originally Posted by Ice(v)an View Post
So in my class.

typedef int myArray

class

private:

myArray = anArray[20]

Now should I create a random number code, that will then be stored into the Array, or do I put a code in the main, asking the user to input 20 numbers?

That should be:

Code:
typedef int MyArray;

private:

MyArray anArray[20];

The assignment doesn't say, so you can probably do either way. I think using random numbers is preferrable, so that when you are testing this you don't have to keep typing stuff in.
MuKen is offline   Reply With Quote
Old 29-02-2008, 12:02 AM   #1096
ANBU
 
arbri's Avatar


Join Date: Oct 2006
Posts: 1,309
Rep Power: 0
arbri has a little shameless behaviour in the past
Default Re: Homework Help v1.3

you basically use typedef to hide your implementation, from the client, its just a good principle of programming.so that you can change your data without bothering the client.
arbri is offline   Reply With Quote
Old 29-02-2008, 01:52 AM   #1097
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

How would I put in random numbers into my array?
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 29-02-2008, 03:42 AM   #1098
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

Well, they don't have to be randomly generated, it looks to me. Your teacher just wants you to demonstrate the functionality of the class. So you can just have a main function that calls your add function a bunch of times with whatever numbers you want, and then retrieves elements and prints them.
MuKen is offline   Reply With Quote
Old 29-02-2008, 04:31 AM   #1099
Akatsuki
 
Ice(v)an's Avatar


Join Date: Nov 2004
Location: Urahara Store
Posts: 9,396
My Mood:
Rep Power: 36
Ice(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant futureIce(v)an has a brilliant future

Basic Bronze 
Total Awards: 1

Default Re: Homework Help v1.3

what would that accomplish?
__________________



thanks to Tom, ~Mrge and Simonarturo, EE
Ice(v)an is online now   Reply With Quote
Old 29-02-2008, 04:41 AM   #1100
Donator
 
MuKen's Avatar


Join Date: May 2006
Location: New York City
Posts: 2,649
My Mood:
Rep Power: 21
MuKen has a brilliant futureMuKen has a brilliant futureMuKen has a brilliant future

Basic Gold Basic Bronze Basic Silver 
Total Awards: 3

Default Re: Homework Help v1.3

You're just supposed to show that your class works. Insert a bunch of stuff, then print it out and show that they are in order now.
MuKen is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump