This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 »
586
Announcements / Re: Happy New Year
« on: January 28, 2010, 06:28:18 pm »Exactly. You just did it with a non-class template parameter, which generates a new copy of all member functions for every size. Why not make it a property and pass it to the constructor?AFAIK, I thought that the point of templates is so that you don't waste size copying all of the functions. Meaning that it uses the template to make a function on runtime, or something, unless I'm wrong.
587
Announcements / Re: Happy New Year
« on: January 27, 2010, 08:35:46 pm »Unfortunately, C/C++ arrays have no "length" property, unlike Java arrays. Hence the purpose of my code.That's because it would require storing it in another variable, using up space.
Of course, I could think of ways to optimize my Array/StaticArray classes.
588
General ENIGMA / Re: Useful Tips
« on: January 27, 2010, 08:34:03 pm »
Click here to pronowns something in Ing-lish
589
Announcements / Re: Happy New Year
« on: January 26, 2010, 02:56:25 pm »Well, you could have thisAlso this:Code: [Select]int sum(Array<int>* numbers){
int result = 0;
for(int i = 0; i < numbers->getLength();++i){
result += numbers[i];
}
return result;
}
int main(){
StaticArray<int, 10> array1;
StaticArray<int, 20> array2;
printf("%d\n", sum(&array1) + sum(&array2));
return 0;
}
Code: [Select]
template<class T,int size> int sum(array<T,size> numbers)
{
...
}
EDIT: Rusky, it's not really any more or less efficient. If anything, a template uses less space. And, it's usually a bit cleaner, sometimes.
590
Off-Topic / Re: What do you think of the IPB "Edit" button?
« on: January 26, 2010, 02:54:29 pm »
Leave it separately.
591
Announcements / Re: Happy New Year
« on: January 24, 2010, 09:24:52 pm »I thought about that too, but I didn't remember the syntax for type templates in C++.What exactly is the point of the first class? It doesn't do anything, and you don't really need it.Code: [Select]template <typename T>
class Array{
public:
virtual int getLength() = 0;
};
template <typename T, int size>
class StaticArray : public Array<T>
{
public:
T data[size];
virtual int getLength(){ return size; }
};
int main(){
StaticArray<int, 10> array;
return 0;
}
592
Announcements / Re: Happy New Year
« on: January 20, 2010, 06:55:52 pm »Better example than mine. Although, another thing that I would add is changing void to a class T in the template.Code: [Select]class Array{
public: virtual size_t getLength() = 0;
};
class StaticArray<int length> : public Array{
public:
void* arrayData[T];
virtual size_t getLength(){
return length;
}
}
I didn't bother to check if this compiles, but if this is possible, then it's a more efficient solution for static arrays with a getLength property than the ones I used in the past.
593
General ENIGMA / Re: Enigma on other platforms
« on: January 20, 2010, 06:53:56 pm »
If we're talking about homebrew, well, yeah, the Wii wins. But, this is about official stuff.
Also, handheld != console.
Also, handheld != console.
594
Announcements / Re: Happy New Year
« on: January 20, 2010, 03:23:32 pm »So basically manual RTTI and/or virtual functions?RTTI, yes, virtual functions... I guess, but not really.
Bad example, but:
Code: [Select]
template<bool negative> class number
{
public: uint64 value;
public: bool is_negative() { return negative; }
}
595
General ENIGMA / Re: Enigma on other platforms
« on: January 20, 2010, 03:17:43 pm »It's built to be a gaming platform so the experience on the 360 v. the PC will usually be better.Depends on the opinion. Personally, I like the PC gaming experience, better.
Quote
It's also better hardware-wise than the Wii and cheaper than the PS3, so the shared games aren't much of a problem either.A valid point as well, however, the price of XBL makes the price almost not make a difference.
Quote
Basically, it doesn't suck.In my opinion, all of the current consoles suck.
But, if you want to compare:
- Wii has some good games, crap hardware (relatively speaking), and tons of bad games
- PS3 has few games, but most of them are good, and you can use the console for other things than just games
- 360 is just a PC without the PC part and only games, and you have to pay for online; if you really want to use a console instead of a PC for games (and multiplayer on the same console), it is good, but besides that, it doesn't really have any unique aspects
596
Off-Topic / Re: breaking news I AM A GIGANTIC FAGGOT PLEASE BAN ME blast breaking captcha code
« on: January 19, 2010, 03:57:05 pm »
Do we ever get miniature faggots?
597
General ENIGMA / Re: Enigma on other platforms
« on: January 19, 2010, 03:52:31 pm »How is it a terrible console? It seems that you hate everything decent that Microsoft has made just because not everything they make is decent.The 360 is a terrible console for the reason that almost every game for the 360 is on the PC, 1/5 of the 360s get RRODs, and the fact that most of the games tend to be flat-out boring first-person shooters (and the ones that aren't are on the PS3/Wii, too).
*sniff* I smell uninformed suck-upI honestly have no counter-argument, as most of it is true. But a lot of that could be said about most everyone else, too, despite the fact that I do it more than everyone else. Also, fyi, I'm not as bad as I was about six months to a year ago.
He's just pointing out that RetroX has no reason for his position, and that he has long history of this.
And because you're probably going to misunderstand this post too, I'm just pointing out that you are just posting inflammatory crap just to create an image for yourself.
598
Announcements / Re: Happy New Year
« on: January 18, 2010, 07:40:35 pm »...why do you need templates for that?So that you can have a constant value in a certain class as a type. That class alone is useless, but you can store other things in it. That meaning, you can actually find out what class is what and perform an action based upon this depending on what the class is.
599
Announcements / Re: Happy New Year
« on: January 17, 2010, 10:39:57 am »What's with the const? Template parameters take the pickiest form of const you can even imagine. That's like prefixing "long" to a Bignum.
Code: [Select]
template<int id> class thing
{
public: int get_id() { return id; }
}
600
Announcements / Re: Happy New Year
« on: January 16, 2010, 12:04:47 pm »In C++ you can make statically-allocated containers of varying sizes:Code: [Select]template <typename Value, int size>
class Stack {
private:
Value value[size];
public:
...
};
or create constant values for classes:
Code: [Select]
template<const int id> class thing
{
public: const int get_id() { return id; }
}