Page 2 of 4

Re: Confusion

Posted: Sun Jan 23, 2011 8:25 am
by GroundUpEngine
xiphirx wrote:

Code: Select all

         typedef std::vetcor<Instance> Vetcor;
Stopped reading there.
I concur :lol:

Re: Confusion

Posted: Sun Jan 23, 2011 8:50 am
by N64vSNES
THe Floating Brain wrote:Beacuse I did not want to deal with pre-prosser commands
You're really not understanding what people are asking are you?

Why would you want your code to look this this?

Code: Select all

Instance MyClass {

};
I fail to see the point in this. Also testing that line in VC++ 2008 it gives a warning.

Re: Confusion

Posted: Sun Jan 23, 2011 9:26 am
by D-e-X
I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.

Re: Confusion

Posted: Sun Jan 23, 2011 2:46 pm
by Ginto8
D-e-X wrote:I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
also, please understand that a specific syntax is used by the language for a very specific reason. Using preprocessor to CHANGE the syntax of the language is like trying to chop off someone's legs just because you like midgets better.

Re: Confusion

Posted: Sun Jan 23, 2011 3:45 pm
by D-e-X
Ginto8 wrote:
D-e-X wrote:I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
also, please understand that a specific syntax is used by the language for a very specific reason. Using preprocessor to CHANGE the syntax of the language is like trying to chop off someone's legs just because you like midgets better.
^ this is true.

Re: Confusion

Posted: Sun Jan 23, 2011 4:03 pm
by N64vSNES
Ginto8 wrote:
D-e-X wrote:I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
also, please understand that a specific syntax is used by the language for a very specific reason. Using preprocessor to CHANGE the syntax of the language is like trying to chop off someone's legs just because you like midgets better.
What a genius way of putting it....

Re: Confusion

Posted: Sun Jan 23, 2011 4:11 pm
by Ginto8
N64vSNES wrote:
Ginto8 wrote:
D-e-X wrote:I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
also, please understand that a specific syntax is used by the language for a very specific reason. Using preprocessor to CHANGE the syntax of the language is like trying to chop off someone's legs just because you like midgets better.
What a genius way of putting it....
crazy analogies are my specialty ;)

Re: Confusion

Posted: Sun Jan 23, 2011 5:01 pm
by avansc
Not to pick any sides, or say one way is better than the other, but you do sometimes see typedefs going on.

for instance, with returning function pointers it is a lot easier to do.

Code: Select all

typedef float(*pFunc)(args, ...);
pFunc foo(args, ...);
also, if you have ever dabbled in C, you would have probably had to typedef some of your structs. (well not had to, but i dont wanna write struct out every time i have to declare one.)

Code: Select all

typedef struct
{
    bla bla bla
} bla, *pBla;

and then onto C++, you sometimes do see this aswell, usually to make things easier on the programmer, afterall, is that not what programming is about?
http://en.wikipedia.org/wiki/Typedef
"

Code: Select all

std::vector<std::pair<std::string, int> > values;
for (std::vector<std::pair<std::string, int> >::const_iterator i = values.begin(); i != values.end(); ++i)
{
   std::pair<std::string, int> const & t = *i;
   // do something
}

Code: Select all

typedef std::pair<std::string, int> value_t;
typedef std::vector<value_t> values_t;
 
values_t values;
for (values_t::const_iterator i = values.begin(); i != values.end(); ++i)
{
   value_t const & t = *i;
   // do something
}
"

Re: Confusion

Posted: Sun Jan 23, 2011 5:15 pm
by Ginto8
typedef'ing is fine. It does not actually change the syntax of the language. However, renaming the KEYWORD "class" to "Instance" is not only unnecessary, clumsy, and downright bad programming, it also misleads people as to what a program actually does. A class is not an instance, and therefore should not be called one. Renaming "class" to "type" would be just as unnecessary and clumsy, but it would be less bad because it does not mislead whoever reads the code.

Re: Confusion

Posted: Mon Jan 24, 2011 2:43 pm
by N64vSNES
What he said^ ;)

Although I've used it for function pointers.

Re: Confusion

Posted: Mon Jan 24, 2011 4:47 pm
by THe Floating Brain
Well lots of talk on this while I was gone XD. Reason being for that is just to make it easier to take any instance of any class for a function argument (the implimentation for this is show in the topic post).
A class is not an instance, and therefore should not be called one.
I am well aware that a class is not a instance. The purpose of this function is to feed a instance of a class into a element of a std::vector or a array.
I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
I fully understand the fundamentals of C++, maybe im a little messy in my work but I do understand C++.
usually to make things easier on the programmer, after all, is that not what programming is about?
Thank you avansc :-) The whole reason for this typedef is simply to make things easier!
GroundUpEngine wrote:
xiphirx wrote:

Code: Select all

 typedef std::vector<Instance> Vector;
Stopped reading there.
I concur :lol:
I already explained that I was using that to test stuff (although agreed it is bad practices) and I forgot to take it out.
xiphirx wrote:
THe Floating Brain wrote:Because I did not want to deal with pre-prosser commands
wat

are you a troll by chance?
How is that trolling?!?!?!

Re: Confusion

Posted: Mon Jan 24, 2011 5:10 pm
by N64vSNES
THe Floating Brain wrote:Well lots of talk on this while I was gone XD. Reason being for that is just to make it easier to take any instance of any class for a function argument (the implimentation for this is show in the topic post).
A class is not an instance, and therefore should not be called one.
I am well aware that a class is not a instance. The purpose of this function is to feed a instance of a class into a element of a std::vector or a array.
I'm giving you a tip, man, just please... go through the fundamentals of C++ one more time, and this time, make sure you UNDERSTAND every concept and how to use it... or at least, please brush up on it.
I fully understand the fundamentals of C++, maybe im a little messy in my work but I do understand C++.
usually to make things easier on the programmer, after all, is that not what programming is about?
Thank you avansc :-) The whole reason for this typedef is simply to make things easier!
GroundUpEngine wrote:
xiphirx wrote:

Code: Select all

 typedef std::vector<Instance> Vector;
Stopped reading there.
I concur :lol:
I already explained that I was using that to test stuff (although agreed it is bad practices) and I forgot to take it out.
xiphirx wrote:
THe Floating Brain wrote:Because I did not want to deal with pre-prosser commands
wat

are you a troll by chance?
How is that trolling?!?!?!
Would you please listen to what people are saying? typedef's are there to make things easier but they're not to be abused.

To typedef a struct is perfectly understandable since it will make code easier to read.
To typedef a function pointer is fine they look like shit anyway.
To typedef the class keyword is just retarded.

Like I said before visual studio dosen't even approve of this:

Code: Select all

warning C4091: 'typedef ' : ignored on left of 'Instance' when no variable is declared
Level 3 warnings^
You shouldn't ignore your warnings. Remove this and you're one step closer to your program working properly.

Re: Confusion

Posted: Mon Jan 24, 2011 5:43 pm
by THe Floating Brain
Very well then I will admit I do not exactly read up on format :oops: . Is a template okey instead of a typedef? Please dont yell at me :cry: .
P.s
To typedef the class keyword is just retarded.
Correct term is "Developmentaly Challanged" use of the word "retared" is outdated. (Have worked with poeple whom actualy have that realy sad :-( ).

Re: Confusion

Posted: Mon Jan 24, 2011 6:10 pm
by Ginto8
The term is mental retardation. They're very stupid because either their brain is not fully developed or it just doesn't function correctly, but being "Developmentally Challenged" is ambiguous and definitely not descriptive enough. Please cut the PC bullshit here. ;)
Also, the "any instance of any class" thing makes me think you're looking for polymorphism, or simply templating. Which it is, I can't tell, because your description is too vague and your understanding is obviously too little.

Re: Confusion

Posted: Mon Jan 24, 2011 8:02 pm
by THe Floating Brain
Ginto8 wrote:The term is mental retardation. They're very stupid because either their brain is not fully developed or it just doesn't function correctly, but being "Developmentally Challenged" is ambiguous and definitely not descriptive enough. Please cut the PC bullshit here. ;)
Also, the "any instance of any class" thing makes me think you're looking for polymorphism, or simply templating. Which it is, I can't tell, because your description is too vague and your understanding is obviously too little.
It is the updated term (http://www.wordwebonline.com/en/DEVELOP ... CHALLENGED)(basicly a more polite version of the term) I do not want to start a fight so that is all I will say. Anyway moving onto softwere development.
The best example I can think of is game maker 8's "instance_create(x, y, whatever)" function somehow you just type the name of the class you want to make and where yo uwant it and BAM it magicly appers on the screen what I have tried to do here is replicate it. Buuuuut the only way I have been able to figure out how to do this without memory heap allocation is by creating a instance(we will just call the instance of the class pizza for the purposes of explination) of what I want to make. Then inputing pizza into my CreatInstance function argument and having that function fill a element of a std::vector or array with a copy of the original instance(pizza)
Ex.

Code: Select all

//pseudo code.//
template<class Instance>
Instance CreateInstance(Instance A)
{
    return A;
}
class food
{
public:
};
food pizza;
std::vector<food> B;
B.push_back(CreateInstance(pizza));
I tried doing this through means of polymorphisim and a factory but I could not get it to work without memory heap allocation :-(
P.s What are you refering to when you say my understanding is to little the particlar topic, C++, format?(Again I do say I do understand C++)