C++ Learning Community Forum
August 01, 2010, 03:00:09 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: A queation about templates  (Read 615 times)
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« on: May 18, 2009, 09:01:34 AM »

I was just wondering, as most of you know i have little to no experience with templates.
Anyway, I just recently took a course on java and I was wondering what the differences between java's abstract classes and C++ templates are?
Logged


Imagine the impossible, then make it happen.
C-Man
Does anyone even read this ?
Global Moderator
Dr. of C++ology
*****
Posts: 988



View Profile WWW
« Reply #1 on: May 18, 2009, 10:18:41 AM »

I have little to no knowlage of jave  Grin
Logged

kccc
I think we have an answer to C-Man's question in his title.
Geek
*****
Posts: 147


View Profile
« Reply #2 on: May 18, 2009, 11:35:02 AM »

No. Abstract methods of abstract classes in Java are simply declarations and still have to have precise signatures (abstract int hit(); there's no way of having one return anything else than int if you specify int), but will not be defined in the super class. You must subclass them. Almost exactly like abstract classes in C++ methinks.
Logged
mleveill
1337 L0LCoder
C++ Freak
***
Posts: 430


IM IN UR PROGRAMZ WRITIN UR CODEZ!


View Profile
« Reply #3 on: May 20, 2009, 04:51:50 AM »

i think you should be comparing java's generics and c++'s templates
i don't think either of them are implemented all that well
Logged

Quote from: kohlrak
Common interests aren't always the best thing. Especially programming wise.
I could just picture a couple fighting over weather to "xor eax by eax" or "and eax by 0"...
Then kids'll come home and argue with their parents that readabilty is better than size and that "mov eax, 0" would be best because that's "more readable." (Even if it really isn't...)

LOLCode - http://lolcode.com/home
myork
Global Moderator
C++ guru
*****
Posts: 1147


View Profile
« Reply #4 on: May 21, 2009, 04:26:04 PM »

C++ has abstract classes.

Just create a class with pure virtual function.

Templates are a very advanced form of Java Generics.
Generics basically covers what templates was originally conceived to-do before everybody realized that templates was really a Turing complete mete-language and much more powerful than originally expected.
Logged
shash4evr
Nerd
****
Posts: 74


View Profile
« Reply #5 on: May 25, 2009, 04:21:28 PM »


 there is no relation between java abstract classes and the c++ templates. Abstraction is a concept in OOP and c++ templates are basically similar to functionality of the java collection classes.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!