DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   How to use typedef for the template structure? What its syntax? (http://www.daniweb.com/forums/thread150300.html)

gregorynoob Oct 10th, 2008 5:46 pm
Re: How to use typedef for the template structure? What its syntax?
 
Quote:

Originally Posted by Rhohitman (Post 709597)
I didn't get what your syntax says. :confused:
Can you kindly explain it..

umm, sorry if it was not understandable, i tried to come up with a very long name for a type i want to define... so i made the name myself, don't try it it won't work. unless you define such a class. which would be silly... c++ isn't java :P

Rhohitman Oct 10th, 2008 7:17 pm
Re: How to use typedef for the template structure? What its syntax?
 
Quote:

Originally Posted by ArkM (Post 709664)
Typedef name is an alias for the type, it's not a new type name.
Can you explain what a problem are you trying to solve with "generic typedef"?

I got your point..
But lets say If i want to create the pointer variable.
like for example normally what we do is

struct box 
{
 ... blah .. blah.. blah
};

typedef box *crazy_box;
//as we can now easy create the pointer with crazy_box
crazy_box B1;

Now I want this to happen with the template structure what to do...

Rhohitman Oct 10th, 2008 7:19 pm
Re: How to use typedef for the template structure? What its syntax?
 
Quote:

Originally Posted by ArkM (Post 709723)
Hehe...
template<typename T> 
struct MyGreatBeautifulBox:box<T>{};

int main()
{
    MyGreatBeautifulBox<int>  ibox;
    MyGreatBeautifulBox<char> cbox;

Hey that Cheating. This is not what i meant for.. :sad:


All times are GMT -4. The time now is 8:28 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC